You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While this example is contrived, what's surprising about the behavior is that Next.js gets into an infinite loop, but only when making the request with a browser.
This suggests to me that the client-side router is misbehaving when the redirect response's location header is empty (notable in the browser response headers above). It should probably attempt to detect redirect loops like modern browsers do.
Expected behavior:
redirect("") should maybe throw an error?
The client-side router should detect simple redirect loops like this.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6020
Available memory (MB): 65536
Available CPU cores: 12
Binaries:
Node: 23.3.0
npm: 10.9.0
Yarn: 1.22.22
pnpm: 10.2.0
Relevant Packages:
next: 15.2.4 // Latest available version is detected (15.2.4).
eslint-config-next: N/A
react: 19.1.0
react-dom: 19.1.0
typescript: 5.8.2
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Redirects
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local), next build (local)
Additional context
I tested on v15.2.4, and v15.1.7.
The text was updated successfully, but these errors were encountered:
This impacts redirects in next.config.js as well. If using the config below and then visiting /beta, an infinite loop occurs. Confirmed Location header in the 308 response is an empty string which seems like the same issue as this
Link to the code that reproduces this issue
https://github.com/mbranch/next.js-redirect-bug
To Reproduce
# Browser response headers HTTP/1.1 200 OK Vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Router-Segment-Prefetch, Accept-Encoding Cache-Control: no-store, must-revalidate Content-Type: text/x-component Content-Encoding: gzip Date: Fri, 28 Mar 2025 22:18:40 GMT Connection: keep-alive Keep-Alive: timeout=5 Transfer-Encoding: chunked
Current vs. Expected behavior
While this example is contrived, what's surprising about the behavior is that Next.js gets into an infinite loop, but only when making the request with a browser.
This suggests to me that the client-side router is misbehaving when the redirect response's
location
header is empty (notable in the browser response headers above). It should probably attempt to detect redirect loops like modern browsers do.Expected behavior:
redirect("")
should maybe throw an error?Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6020 Available memory (MB): 65536 Available CPU cores: 12 Binaries: Node: 23.3.0 npm: 10.9.0 Yarn: 1.22.22 pnpm: 10.2.0 Relevant Packages: next: 15.2.4 // Latest available version is detected (15.2.4). eslint-config-next: N/A react: 19.1.0 react-dom: 19.1.0 typescript: 5.8.2 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Redirects
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local), next build (local)
Additional context
I tested on v15.2.4, and v15.1.7.
The text was updated successfully, but these errors were encountered: