Next.js Discord

Discord Forum

Next (13.2.4) not redirect in build mode after set cookie

Unanswered
Ratonero Valenciano posted this in #help-forum
Open in Discord
Avatar
Ratonero ValencianoOP
'm trying to authorize through cookies and middleware. In dev mode, everything works fine. But in the assembly (npm run build) the redirect does not work after the cookies are set. I do not understand why in dev mode everything works as it should, but in the build the redirect does not work. In this case, cookies appear
Image
Image
Image

5 Replies

Avatar
DirtyCajunRice | AppDir
you need to return the redirects
no idea why that even works in dev
Avatar
Ratonero ValencianoOP
If I return a redirect, then I have an infinite redirect. Only works if I return NextResponse.next()
Avatar
DirtyCajunRice | AppDir
then you arent redirecting. you either return next OR redirect. you need to fix your logic.
Avatar
Ratonero ValencianoOP
Thx, bro. I fixed this ❤️