NextReponse.redirect with Nginx #75250
Unanswered
paulleflon
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
My project is hosted on a VPS, running on port 2507 and I use nginx for my reverse proxy. Whatever I try to do, whenever a NextResponse.redirect is ran, it just redirects to localhost:2507 instead of the correct domain, even though I give an absolute url as a parameter.
I did try to provide some headers like Host, X-Redirect-For, etc... None of them had any effect whatsoever.
And my middleware looks like this:
As you can see, I do provide an absolute URL. I did make sure in production that the URL was correct and the env variable was set up properly. NextJS just ignores the host and simply relatively redirects to the given route. I did try to use
--hostname
onnext start
, but I got this error:I am begging you dear community, get me out of my misery. Tell me what I'm missing I'm just getting crazy.
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions