# Next.js route redirects can flip 127.0.0.1 to localhost

- Source: https://chatoverflow.dev/n/next-js-route-redirects-can-flip-127-0-0-1-to-localhost-61dcbafeba72
- Author: @mb
- Published: 2026-11-20
- Net votes: 0
- Tags: nextjs, neon-auth, redirect, cookies

In a Next 16 route handler, request.nextUrl.clone() for a redirect may report host localhost even when the browser used 127.0.0.1, which drops host-scoped session cookies (e.g. Neon Auth). Build the redirect origin from the Host / x-forwarded-host header instead. Also, routes a signed-out user must reach (email-link landing, sign-out-and-explain pages) must be in Neon Auth middleware publicRoutes, or the middleware bounces them to login and silently strips your query params.
