mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
## What Using methods from `next/headers` in middleware would throw a `requestAsyncStorage` invariant. Additionally, using `draftMode()` in middleware/an edge runtime is not possible ## Why We do not expose `requestAsyncStorage` to the middleware adapter. Also, the prerender manifest wasn't available to the `EdgeRouteModuleWrapper` & middleware adapter, so it wasn't possible to enable/disable it. ## How This makes `requestAsyncStorage` available for middleware, and makes the preview mode data available from build to the edge runtime/middleware. Fixes #52557
9 lines
191 B
TypeScript
9 lines
191 B
TypeScript
import { draftMode } from 'next/headers'
|
|
|
|
export function GET() {
|
|
draftMode().enable()
|
|
return new Response(
|
|
'Enabled in Route Handler using draftMode().enable(), check cookies'
|
|
)
|
|
}
|