Closed JKarlavige closed 2 months ago
@JKarlavige
Hi. I am not quite understand implementation of draft mode, but it seems like isEnable
is readonly and no chance to be updated when enable()
or disable()
is called.
May be you can use request.cookies.has('__prerender_bypass')
to test whether draft mode is enabled or not.
https://github.com/vercel/next.js/issues/52080#issuecomment-1785039348
Quick question on Draft Mode - does it require integration of a Headless CMS or can we use it without one?
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Link to the code that reproduces this issue
https://github.com/JKarlavige/nextjs-draftmode-reproduction
To Reproduce
npm i
npm run dev
localhost:3000/api/draft?secret=secret-token&slug=preview-page
Current vs. Expected behavior
Note - Draft mode on the page itself works correctly.
draftMode().isEnabled
returns true.Current behavior: In middleware,
draftMode().isEnabled
returnsfalse
after hitting the draft endpoint in step 4 above.Expected behavior:
draftMode().isEnabled
should returntrue
after the draft endpoint has been hit.Provide environment information
Which area(s) are affected? (Select all that apply)
Middleware
Which stage(s) are affected? (Select all that apply)
next dev (local), Vercel (Deployed)
Additional context
On
next
version 14.1.4 (which we currently use in production), we experience inconsistencies where draft mode in middleware sometimes returnstrue
, and on the following middleware run it returnsfalse
.On version 14.2.4, it appears that draft mode always returns
false
.