fix(nuxt): only send the source-map header in draft mode - #153
Open
PaulBratslavsky wants to merge 1 commit into
Open
fix(nuxt): only send the source-map header in draft mode#153PaulBratslavsky wants to merge 1 commit into
PaulBratslavsky wants to merge 1 commit into
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 anycustom header makes a cross-origin request preflighted. Strapi's CORS
defaults answer with:
The header is not in that list, so the preflight fails, the fetch throws,
page.valueis null, and the page throws its own 404 — which is why thesymptom looks like a missing route rather than a blocked request.
Confirmed against Strapi directly:
The fix
The header only means something when
draftis true. Sending"false"therest 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/contactand/en/faqall render, with zero CORS errorsin the console. Nuxt build clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GQSJu9Etpa6qjCny1CPWcc