Search params are undefined when draft mode is enabled #70384
Replies: 7 comments 4 replies
-
|
As an aside, how actively are these issues monitored? I've submitted 2 bugs months ago which have yet to be acknowledged by a maintainer |
Beta Was this translation helpful? Give feedback.
-
|
Edited to add an example of a production build run locally which also works as expected, which confirms a discrepancy between a production app built and run locally vs on Vercel |
Beta Was this translation helpful? Give feedback.
-
@MangoMarcus Actively as possible! We are currently taking a look at this. |
Beta Was this translation helpful? Give feedback.
-
Thanks @samcx 🙏 |
Beta Was this translation helpful? Give feedback.
-
|
@MangoMarcus It turns out your page was not bailing out of ISR (static) because I tried just adding: Afterwards, token is no longer I am curious though as to why you want to access your |
Beta Was this translation helpful? Give feedback.
-
|
I'm also encountering this issue. I want to access |
Beta Was this translation helpful? Give feedback.
-
|
@jalada nice to have company! Vercel support have basically washed their hands of this as the expected behaviour, even though it works fine locally using a production build, and on Netlify, but not Vercel. Maybe the fix is to move to Netlify 🤔
They did however suggest a workaround using headers instead of search params, I haven't tested that but it wouldn't work in my case anyway because I don't have control over the headers coming from my CMS backend.
I'm not sure why headers should work but search params shouldn't during dynamic rendering anyway to be honest. As you say, the page is being rendered dynamically as expected - it's just not providing the search params from the request. |
Beta Was this translation helpful? Give feedback.



Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Link to the code that reproduces this issue
https://github.com/MangoMarcus/nextjs-draft-mode-empty-search-params
To Reproduce
npm iandnpm run devCurrent vs. Expected behavior
Locally the token correctly displays as 'foo' with draft mode enabled, but on Vercel it's 'undefined'. Vercel should also show 'foo'.
Interestingly there's also a discrepancy between
urlPathnameandisRevalidatebetween local and vercel shown in the screenshots belowLocal - dev mode (
npm run dev)Draft mode disabled

Draft mode enabled

Local - production build (
npm run build && npm start)Draft mode disabled

Draft mode enabled

Vercel
Draft mode disabled

Draft mode enabled

Provide environment information
Which area(s) are affected? (Select all that apply)
Output (export/standalone), Runtime
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Additional context
The problem might stem from the search parameter being accessed dynamically, depending on if draft mode is enabled.
If draft mode is enabled then the page is rendered dynamically and dynamic features like search parameters and cookies should be available. If it's disabled, then it's rendered statically and all search parameters should returned
undefined.My example shows that draft mode is correctly enabled - and therefore the page is being rendered dynamically at request time - but the dynamic features are not available.
Edit: Added local production build examples
Beta Was this translation helpful? Give feedback.
All reactions