Skip to content

fix: invalid CORS header combo blocks SPA load#385

Merged
aktech merged 1 commit into
mainfrom
fix/cors-header-combo
Jun 5, 2026
Merged

fix: invalid CORS header combo blocks SPA load#385
aktech merged 1 commit into
mainfrom
fix/cors-header-combo

Conversation

@aktech

@aktech aktech commented Jun 5, 2026

Copy link
Copy Markdown
Member

Fixes #384.

corsMiddleware set both Access-Control-Allow-Origin: * and Access-Control-Allow-Credentials: true. That combination is invalid per the CORS spec, so browsers reject the response. Behind a gateway this blocks the SPA's <script type="module" crossorigin> bundle from loading, leaving users in a /login reload loop.

The API is reached with a bearer Authorization header (CLI and same-origin SPA), never cross-origin cookies, so the credentials header buys nothing. Removed it; kept the wildcard origin.

* without credentials is safe here: a cross-origin browser request defaults to no-credentials, so the OIDC IdToken cookie is never sent and only unauthenticated endpoints are reachable cross-origin.

Test drives the real NewRouter (real CORS wiring + embedded-SPA static handler) and asserts the invalid combo is gone; verified it fails on the old behavior.

The Cache-Control: no-store on static assets noted in the issue is left for a separate change.

@netlify

netlify Bot commented Jun 5, 2026

Copy link
Copy Markdown

Deploy Preview for nebi-docs canceled.

Name Link
🔨 Latest commit 252e03e
🔍 Latest deploy log https://app.netlify.com/projects/nebi-docs/deploys/6a22b52554d65b0008153eaa

corsMiddleware set both Access-Control-Allow-Origin: * and
Access-Control-Allow-Credentials: true. That pairing is invalid per the
CORS spec, so browsers reject the response. Behind a gateway this blocks
the SPA's <script type="module" crossorigin> bundle from loading, leaving
users in a /login reload loop.

The API is reached with a bearer Authorization header (CLI and same-origin
SPA), never cross-origin cookies, so the credentials header is unneeded.
Remove it and keep the wildcard origin.

Test drives the real NewRouter (real CORS wiring + embedded-SPA static
handler) and asserts the invalid combo is gone.
@aktech aktech force-pushed the fix/cors-header-combo branch from ef1b582 to 252e03e Compare June 5, 2026 11:38
@aktech aktech merged commit 047197b into main Jun 5, 2026
14 checks passed
@aktech aktech deleted the fix/cors-header-combo branch June 5, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

corsMiddleware emits invalid CORS header combo, blocks browser SPA load

2 participants