Next.js Discord

Discord Forum

multiple Next.js apps with draft preview cookie on localhost

Unanswered
Sokoke posted this in #help-forum
Open in Discord
SokokeOP
Hey,

we have two different Next.js apps as a single project. The problem is we need to have a draft preview mode enabled for both of the applications. Unfortunatley, on localhost, Next.js cookies for the draft preview (with the name __prerender_bypass), conflict between those apps since they are both set for the domain localhost and when I enable preview mode for the second application and come back to the first application and refresh the page, the cookie is probably taken as invalid and is deleted for both apps.

What would be the solution here?, can I modify the cookie somehow in a config (for example change the name for the second app). Any ideas how to handle this will be highly appreciated 🙂

18 Replies

@gin yes u can
SokokeOP
I couldnt find anything in the docs, would you tell me where this config is?
how are u setting cookies?
i dont know what u use so i cant give u docs or something
SokokeOP
Next.js sets those cookies for you, Iam talking about this feature https://nextjs.org/docs/pages/building-your-application/configuring/draft-mode
Cant u set this cookie yourself
So extend the function and have your own enable() function
and isEnabled checks for your cookie
that u have set in the config
bypassToken
nah but i guess this wont work
since nexts is internally tracking for draftMode itself
I think setting a custom cookie is not available yet
SokokeOP
I can set my own cookie but it wont have the same effects
yeah
maybe open a request on github
i cant help u sry