Skip to content

Cloudflare Workers

For server-side compilation:

  • Use the jspi backend. Do not create a Web Worker or add browser isolation headers.
  • Use the Cloudflare Vite plugin for Vite builds. It handles the .wasm imports used by the Worker and includes them in the deployment.

Responses used only for server-side compilation do not need Cross-Origin-Opener-Policy or Cross-Origin-Embedder-Policy.

/*
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

For HTML generated by a Worker or SSR framework, configure middleware or set the headers on the Response itself. A _headers file only applies to static assets; it does not modify responses returned directly by Worker code. Browsers using JSPI may not need these isolation headers. require-corp can also block third-party images, scripts, fonts, and embeds, so prefer same-origin resources or configure CORS/CORP for every cross-origin resource. See the browser deployment requirements for the full checklist.

Use an ASSETS binding when Worker code reads files emitted as static assets, for example when loading packaged font URLs into compiler.addFonts(). Configure the binding in wrangler.jsonc; the Cloudflare Vite plugin manages the generated asset directory:

{
"assets": { "binding": "ASSETS" },
}

A browser-only static deployment can instead configure the asset directory without exposing an ASSETS binding to Worker code.