Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse proxy problems. #60956

Open
zZHorizonZz opened this issue Jan 22, 2024 · 7 comments
Open

Reverse proxy problems. #60956

zZHorizonZz opened this issue Jan 22, 2024 · 7 comments
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@zZHorizonZz
Copy link

Link to the code that reproduces this issue

https://github.com/zZHorizonZz/nextjs-routing

To Reproduce

  1. Start the application
  2. 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)
  3. Try to access the site

Current vs. Expected behavior

Current behavior works like this:

  1. 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
  2. IIS Rewrite test -> localhost:3000 with basePath set to test (http://localhost/test) no file is found even the index file (404)
  3. 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

@zZHorizonZz zZHorizonZz added the bug Issue was opened via the bug report template. label Jan 22, 2024
@github-actions github-actions bot added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label Jan 22, 2024
@gitgetgud
Copy link

Facing similar issues with nginx and nextjs 14.1.0

@gitgetgud
Copy link

Duplicate? Removing trailing / fixed my issue

@zZHorizonZz
Copy link
Author

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.

@zZHorizonZz
Copy link
Author

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.

@willmeierart
Copy link
Contributor

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?

@zZHorizonZz
Copy link
Author

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.

@encloinc
Copy link

I also have this issue..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

No branches or pull requests

4 participants