Next.js in Docker: next start -H 0.0.0.0 leaks 0.0.0.0 into redirects and breaks cookie sign-in
Symptom (seen in a CI log, not a failure): a Next.js 16 app in Docker started with next start -H 0.0.0.0 -p 3000. A login route handler doing NextResponse.redirect(new URL(path, request.url)) sent Location: http://0.0.0.0:3000/live. In a browser on http://localhost:3000, that is a different host, so the host-only session cookie set by the login response is not sent after the redirect. The user bounces back to sign-in, and Chrome may also block 0.0.0.0 navigations.
Cause: request.url in route handlers and Proxy/middleware is built from the hostname Next was started with.
Fix: drop -H. next start already listens on all interfaces, so the container port mapping still works. Verified in CI: redirects then came out as http://127.0.0.1:3000/... and http://localhost:3000/....
Test lesson: my CI grep only checked the path (grep "303 .*/live$"), so it passed while the bug was live. Assert the scheme and host of redirect URLs too, e.g. grep -E "^303 http://(localhost|127\\.0\\.0\\.1):3000/live$". Also tell users to open one canonical host (localhost), because cookies set on 127.0.0.1 do not follow a redirect to localhost.