Open phev8 opened 1 year ago
Printing the new URL in both test cases results in the same value, so I assume the difference in behaviour comes form NextResponse.redirect(...)
This might be linked to this comment from last year : https://github.com/vercel/next.js/pull/37925/files#r906559517
After some testing, this issue is not present in v13.4.12, but the behaviour started from v.13.4.13 So likely one of the changed from here: https://github.com/vercel/next.js/releases/tag/v13.4.13
Might this be related to this PR https://github.com/vercel/next.js/pull/53157 (and how requests are cloned when processing the redirect)? @balazsorban44 I don't see too much other related changes from 13.4.12 ->13.4.13
I've just added this bug report which might be related. #54748
The issue still happens with v13.5.1 - so unfortunately cannot use it for now.
The issue still happens with v13.5.1 - so unfortunately cannot use it for now.
Same in 13.5.4. Experiencing the same thing there unfortunately
@leerob Can we get someone from Vercel to have eyes on this? This is extremely bad and unexpected behaviour.
@leerob Related bug https://github.com/vercel/next.js/issues/65568 https://github.com/vercel/next.js/issues/57397 https://github.com/vercel/next.js/issues/58764 https://github.com/vercel/next.js/issues/54450 Could we at least be informed of the status? Is the team working on resolving the issue?
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
Middleware / Edge (API routes, runtime)
Link to the code that reproduces this issue or a replay of the bug
https://github.com/coneno/nextjs-middleware-redirect-issue
To Reproduce
Start dev or test server.
Using:
curl --location 'http://localhost:3000/' --header 'x-forwarded-proto: https' --header 'x-forwarded-proto: https' -i
Results in:Note Location is an absolute path compared to expected redirect (see below).
Describe the Bug
Having a simple redirect middleware:
x-forwarded-proto: https
present in the request header (simulated in curl command to reproduce)x-forwarded-proto: https
in the header, it breaks the application, because it uses an absolute path in the redirect location headerlocalhost:3000/<pathname>
, not the URL from the request (when using on the production server in OpenShift - not sure how to simulate this with dev server without proxy)Expected Behavior
Using:
curl --location 'http://localhost:3000/' --header 'x-forwarded-proto: https' -i
Redirects as expected: (note location being relative)Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
OpenShift behind an Azure Gateway