Skip to content

fix(nuxt): only send the source-map header in draft mode - #153

Open
PaulBratslavsky wants to merge 1 commit into
mainfrom
fix/nuxt-client-nav-404
Open

fix(nuxt): only send the source-map header in draft mode#153
PaulBratslavsky wants to merge 1 commit into
mainfrom
fix/nuxt-client-nav-404

Conversation

@PaulBratslavsky

Copy link
Copy Markdown
Collaborator

Clicking a nav link to a CMS page in the Nuxt demo renders the 404. Loading
the same URL directly, or reloading it, works.

What is happening

The difference is where the fetch runs. A full page load fetches Strapi on
the server; in-app navigation refetches from the browser.

That browser request carried strapi-encode-source-maps: false, and any
custom header makes a cross-origin request preflighted. Strapi's CORS
defaults answer with:

Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept

The header is not in that list, so the preflight fails, the fetch throws,
page.value is null, and the page throws its own 404 — which is why the
symptom looks like a missing route rather than a blocked request.

Confirmed against Strapi directly:

preflight with the header  → 204, header not in Allow-Headers
plain GET without it       → 200

The fix

The header only means something when draft is true. Sending "false" the
rest of the time bought nothing and cost every client-side navigation.
Omitting it keeps those requests simple, so no preflight happens.

Draft mode still sends it, so the preview overlay is unaffected.

Why only Nuxt

Next, Astro and TanStack set the same header unconditionally but never hit
this, because none of them fetch Strapi from the browser — RSC, SSR and
server functions respectively. Left alone rather than changed
speculatively.

Verification

By click-through, not direct loads, since direct loads always worked:
/en/pricing, /en/contact and /en/faq all render, with zero CORS errors
in the console. Nuxt build clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GQSJu9Etpa6qjCny1CPWcc

Clicking a nav link to a CMS page rendered the 404, while loading the same
URL directly worked. The difference is where the fetch runs: a full page
load fetches Strapi on the server, in-app navigation refetches from the
browser.

That browser request carried `strapi-encode-source-maps: false`, and any
custom header makes a cross-origin request preflighted. Strapi's CORS
defaults answer with

    Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept

so the preflight fails, the fetch throws, `page.value` is null, and the
page throws its own 404 — which is why the symptom looked like a missing
route rather than a blocked request.

The header only means anything when draft is true; sending "false" the rest
of the time bought nothing and cost every client-side navigation. Omitting
it keeps those requests simple, and no preflight happens. Confirmed against
Strapi directly: the preflight with the header is refused, a plain GET
returns 200.

Draft mode still sends it, so the preview overlay is unaffected.

Next, Astro and TanStack set the same header unconditionally but never hit
this, because none of them fetch Strapi from the browser — RSC, SSR and
server functions respectively. Left alone rather than changed speculatively.

Verified by click-through, not just direct loads: /en/pricing, /en/contact
and /en/faq all render. Build clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQSJu9Etpa6qjCny1CPWcc
@vercel

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
launch-pad Ready Ready Preview Sep 9, 2026 9:48pm UTC

Request Review

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.

2 participants