Skip to content
SiScaller.
Search
Color theme
EN
Digital Products →
Menu

Reference

Pagefind WebAssembly & CSP Hash Isolation

How to run zero-telemetry client-side full-text search under strict Content Security Policies without unsafe-eval.

By AbdelPublished 1 min readadvanced

Setup

Pagefind compiles its search engine to WebAssembly, and browsers require 'wasm-unsafe-eval' in script-src to instantiate it. Adding that directive site-wide would weaken every page for the sake of one.

Method

  1. Build the index after next build from the prerendered article HTML only.
  2. Add 'wasm-unsafe-eval' in the proxy for the exact route /search, nowhere else.
  3. Check in a real browser that search works, that eval() is still refused on /search, and that other pages carry no WebAssembly permission.

Outcome

All three checks passed. The decision is recorded in ADR 0006, and the route has been in use since Sprint 2. Try it on the search page.

Sovereign Venture Dispatches

Actionable startup feasibility studies, zero-trust architectures, and cognitive decision frameworks delivered directly to your inbox. Double opt-in, zero algorithmic noise.

Discussion

Loading the discussion…