fix(api): revert to forwarding cookie header only#3701
fix(api): revert to forwarding cookie header only#3701dargmuesli wants to merge 1 commit intonuxt:mainfrom
Conversation
|
@dargmuesli is attempting to deploy a commit to the Nuxt Team on Vercel. A member of the Team first needs to authorize it. |
commit: |
📝 WalkthroughWalkthroughThe change updates header construction in Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/runtime/internal/api.ts`:
- Around line 14-17: The headers construction accesses
event.context.nitro.runtimeConfig.csurf.headerName without guarding intermediate
properties and can throw if csurf or runtimeConfig is missing; update the
condition to use optional chaining for the full chain (e.g., check
event?.context?.nitro?.runtimeConfig?.csurf?.headerName and
event?.context?.csrfToken) before using the computed property, and keep the
existing spread of options.headers and cookie logic so the header is only added
when both the headerName and csrfToken are present.
8e060f4 to
2e9ebfb
Compare
2e9ebfb to
967dbf3
Compare
@dargmuesli Can't we just enforce |
|
@farnabaz - I have tested simply overwriting the header of Accept-Encoding in the nuxt.config routeRules but when running in production mode, since v3.11.x whenever using server side rendering, the following errors are still always returned. I even tried removing the header completely - Route Rules: Errors: As a note frontend once the page is loaded and navigating nuxt content works as expected but SSR is still broken |
|
@obj63mc Could you try to monkey patch in node modules and test? |
🔗 Linked issue
Resolves #3695
❓ Type of change
📚 Description
Forwarding all headers can make the fetch request return data with brotli compression which is not expected at the moment. Simple fix is to revert the change to headers used.
I've added an additional change that adds support for Nuxt CSRF protection as provided by the security module which uses the csurf module internally. This was the original reason for allowing more headers. In the future we may add a module option to whitelist a certain set of headers instead, but that's something to discuss in the future. If this feature addition is not wanted, simply remove the second line!
📝 Checklist