next.js
next.js copied to clipboard
Reverse proxy problems.
Link to the code that reproduces this issue
https://github.com/zZHorizonZz/nextjs-routing
To Reproduce
- Start the application
- Create a new reverse proxy nginx or IIS and have it route requests for path test for example. (In the repro repository there is an attached file for IIS page config with rewrite rule configuration)
- Try to access the site
Current vs. Expected behavior
Current behavior works like this:
- IIS Rewrite test -> localhost:3000 (http://localhost/test) This will get the index file but other files are not found as it's pointing to localhost/_next
- IIS Rewrite test -> localhost:3000 with basePath set to test (http://localhost/test) no file is found even the index file (404)
- IIS Rewrite test -> localhost:3000/test with basePath set to test (http://localhost/test) results in error too many redirects
The expected behavior is this should probably route and return the correct files. I found a related discussion to this here
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Enterprise
Binaries:
Node: 20.9.0
npm: N/A
Yarn: N/A
pnpm: 8.6.2
Relevant Packages:
next: 14.1.0
eslint-config-next: 14.1.0
react: 18.2.0
react-dom: 18.2.0
typescript: 5.3.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
App Router, Routing (next/router, next/navigation, next/link)
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local)
Additional context
No response
Facing similar issues with nginx and nextjs 14.1.0
Duplicate? Removing trailing / fixed my issue
Duplicate? Removing trailing / fixed my issue
I don't think this is related to my case as I don't have any trailing / in any of the settings.
After looking into it more closely, I've noticed something unusual. Even the default application returns a 404 error, but the issue is more complex. We receive a valid index response, which includes references to subsequent scripts and other elements, so the responses themselves appear valid. However, something occurs subsequently, and Next.js sets the status of response to 404. The only explanation I can think of is that there might be an issue with invalid headers. Could this be the reason Next.js is marking the request as 404? But that's just a wild guess.
After looking into it more closely, I've noticed something unusual. Even the default application returns a 404 error, but the issue is more complex. We receive a valid index response, which includes references to subsequent scripts and other elements, so the responses themselves appear valid. However, something occurs subsequently, and Next.js sets the status of response to 404. The only explanation I can think of is that there might be an issue with invalid headers. Could this be the reason Next.js is marking the request as 404? But that's just a wild guess.
do the scripts in the index all have the appropriate basePath prepended?
After looking into it more closely, I've noticed something unusual. Even the default application returns a 404 error, but the issue is more complex. We receive a valid index response, which includes references to subsequent scripts and other elements, so the responses themselves appear valid. However, something occurs subsequently, and Next.js sets the status of response to 404. The only explanation I can think of is that there might be an issue with invalid headers. Could this be the reason Next.js is marking the request as 404? But that's just a wild guess.
do the scripts in the index all have the appropriate basePath prepended?
Yes, it does, but I have noticed that when I go to the default path, Next.js starts building the not-found page, which seems weird.
I also have this issue..