Skip to content

WebContainer /headless returns 404 with Referer present and allowed production origin #2135

Description

@harshkasat

Describe the bug

WebContainer.boot() works on localhost but hangs in production because the generated request to https://stackblitz.com/headless returns 404.

This resembles #2056, but our production page does not use Referrer-Policy: same-origin. It currently uses strict-origin-when-cross-origin, and a cross-origin echo test from the page confirms that the browser sends:

Referer: https://freebuff.com/

The API key is enabled and https://freebuff.com is listed under Allowed sites. The client_id query parameter is present and matches that key. Replaying the request with an explicit Referer: https://freebuff.com/ still returns 404.

The account currently uses the free plan. If this key is missing an entitlement required for a production custom origin, could you please confirm that? The API Console permits creating/enabling the key and adding the domain, but /headless only returns a generic 404.

Link to the blitz that caused the error

https://freebuff.com

The production project currently requires authentication. We can provide access or more request details privately. The failure happens before project code or dependencies are mounted: the /headless runtime itself returns 404.

Steps to reproduce

  1. Create and enable a WebContainer API key in the StackBlitz API Console.
  2. Add https://freebuff.com under Allowed sites.
  3. Serve the top-level project page with:
    Cross-Origin-Embedder-Policy: credentialless
    Cross-Origin-Opener-Policy: same-origin
    Referrer-Policy: strict-origin-when-cross-origin
    
  4. With @webcontainer/api@1.6.4, call configureAPIKey() before WebContainer.boot({ coep: 'credentialless' }).
  5. Open the production project page.
  6. Observe that the generated request below returns 404:
    https://stackblitz.com/headless?client_id=wc_api_zedmatedu_…5a7704&coep=credentialless&version=1.6.4
    
  7. WebContainer.boot() never resolves.

The key is partially redacted here because this is a public issue. It can be shared privately if needed.

Expected behavior

The authorized /headless request should return the WebContainer runtime and WebContainer.boot() should resolve.

Parity with Local

  • I have run the project locally and cannot reproduce the issue. Localhost boots successfully.

Screenshots and request evidence

The failed response is an ordinary StackBlitz 404 page and therefore also triggers Chrome's Cross-Origin-Resource-Policy: NOT-SET diagnostic. We believe that diagnostic is downstream of the 404, not its cause.

One failing request:

Timestamp: Mon, 20 Jul 2026 23:21:27 GMT
Status: 404
StackBlitz x-request-id: 82323b76-035b-4816-9ad2-b9149e674e52

A fresh browser-like replay with the correct key, Referer: https://freebuff.com/, iframe fetch headers, and a unique cache-busting parameter also returns 404. Adding corp=1 as discussed in #2100 does not change the 404; we use @webcontainer/api's /headless path rather than @stackblitz/sdk's /run or /edit embed paths.

Platform

  • OS: macOS
  • Browser: Chrome/Chromium 144
  • WebContainer API: 1.6.4
  • Production host: Cloudflare in front of Render

Additional context

The deployed page headers have been verified through Cloudflare and Render. The SDK-created hidden iframe already has allow=\"cross-origin-isolated\". Could a maintainer inspect the request ID above and confirm whether the rejection is due to key/domain propagation, account entitlement, or another authorization condition?

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