Skip to content

fix(build): search returns nothing over file:// (search.js fetches index at runtime) #471

Closed

Description

@sripwoud

The generated static site is documented as browsable directly from disk via file://, but static/js/search.js loads the search index with a runtime fetch(prefix + "/static/search-index.json") and ships no inline fallback. Stock Chromium and Firefox block fetch() between file:// resources (opaque file origins), so search silently returns nothing when the site is opened from disk. Browsing itself works — links are page-relative.

Repro

cook build
chromium --headless=new --dump-dom file:///abs/path/dist/index.html
# search over any term returns no results; console shows "Failed to fetch"

Reproduced on cookcli 0.34.0, with and without --base-url.

Scope

  • Search works fine over any HTTP host (deploy target, python -m http.server) and in browsers that permit local file fetch.
  • Only the file:// open-from-disk path is affected.

Suggested direction

Embedding the index inline (an inline <script> that assigns the JSON, or a JSONP-style loader) would restore file:// search without a network origin. Open to whatever approach you prefer — flagging before implementing in case there's a reason the index is kept external.

Done when

  • Search returns results when the generated site is opened via file://.

Happy to file a PR for this.

Activity

  1. added 2 commits that reference this issue on Sep 3, 2026
    792338f
    1f7a82a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions