Link to the code that reproduces this issue
https://github.com/JKarlavige/nextjs-draftmode-reproduction
To Reproduce
- Clone reproduction repository locally
- Install packages with
npm i
- Run app with
npm run dev
- In a browser, hit the following url:
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 returns false after hitting the draft endpoint in step 4 above.
Expected behavior:
draftMode().isEnabled should return true after the draft endpoint has been hit.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
Available memory (MB): 16384
Available CPU cores: 10
Binaries:
Node: 20.11.1
npm: 10.2.4
Relevant Packages:
next: 14.2.4 // Latest available version is detected (14.2.4).
react: 18.3.1
react-dom: 18.3.1
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 returns true, and on the following middleware run it returns false.
On version 14.2.4, it appears that draft mode always returns false.

Link to the code that reproduces this issue
https://github.com/JKarlavige/nextjs-draftmode-reproduction
To Reproduce
npm inpm run devlocalhost:3000/api/draft?secret=secret-token&slug=preview-pageCurrent vs. Expected behavior
Note - Draft mode on the page itself works correctly.
draftMode().isEnabledreturns true.Current behavior:
In middleware,
draftMode().isEnabledreturnsfalseafter hitting the draft endpoint in step 4 above.Expected behavior:
draftMode().isEnabledshould returntrueafter the draft endpoint has been hit.Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 Available memory (MB): 16384 Available CPU cores: 10 Binaries: Node: 20.11.1 npm: 10.2.4 Relevant Packages: next: 14.2.4 // Latest available version is detected (14.2.4). react: 18.3.1 react-dom: 18.3.1Which 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
nextversion 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.