next.js/test/e2e/app-dir/phase-changes/middleware.ts
middleware.ts18 lines470 B
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*'],
}
Quest for Codev2.0.0
/
SIGN IN