mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
- rename `unstable_after` -> `after` - remove `experimental.after` flag (and warn if it's present) i separated the big find-and-replace into a separate commit so that it's easier to see what else changed apart from that. does not touch docs, that's in #73038
18 lines
470 B
TypeScript
18 lines
470 B
TypeScript
import { cookies } from 'next/headers'
|
|
import { after, type NextRequest } from 'next/server'
|
|
|
|
export async function middleware(request: NextRequest) {
|
|
const url = new URL(request.url)
|
|
|
|
const cookieStore = await cookies()
|
|
if (url.pathname === '/cookies/middleware-to-after/via-closure') {
|
|
after(async () => {
|
|
cookieStore.set('illegalCookie', 'too-late-for-that')
|
|
})
|
|
}
|
|
}
|
|
|
|
export const config = {
|
|
matcher: ['/cookies/middleware-to-after/:path*'],
|
|
}
|