-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Open
Labels
MiddlewareRelated to Next.js Middleware.Related to Next.js Middleware.
Description
Link to the code that reproduces this issue
https://github.com/VeryCrazyDog/nextjs-bug-req-url
To Reproduce
- Clone the minimal reproducible repo.
- Run
npm cito install dependencies. - Run
npm run buildto build standalone output. - Run
node ./.next/standalone/server.jsto run the standalone server. It is expected that the server listening on0.0.0.0on network.▲ Next.js 15.4.0-canary.34 - Local: http://localhost:3000 - Network: http://0.0.0.0:3000 - Access
http://localhost:3000/get/127.0.0.5/show/127.0.0.1from browser. The request URL printed is incorrect.Request URL: http://0.0.0.0:3000/get/localhost/show/127.0.0.1 - Run
npm run devto run server in development mode. - Access
http://server-hostname:3000/get/127.0.0.5/show/127.0.0.1from browser, whereserver-hostnameis the hostname the running server. The request URL is not showingserver-hostname.Request URL: http://localhost:3000/get/127.0.0.5/show/127.0.0.1
Current vs. Expected behavior
Issue 1: Host name is invalid and pathname being altered
When running server using standalone output and accessing http://localhost:3000/get/127.0.0.5/show/127.0.0.1, the request URL printed is:
http://0.0.0.0:3000/get/localhost/show/127.0.0.1
It is expected the printed request URL is the same as the URL being accessed.
http://localhost:3000/get/127.0.0.5/show/127.0.0.1
Issue 2: Host name is incorrect
When running server using development mode and accessing http://server-hostname:3000/get/127.0.0.5/show/127.0.0.1, where server-hostname is the host name the running server, the request URL printed is:
http://localhost:3000/get/127.0.0.5/show/127.0.0.1
It is expected the printed request URL is the same as the URL being accessed.
http://server-hostname:3000/get/127.0.0.5/show/127.0.0.1
Provide environment information
'yarn' is not recognized as an internal or external command,
operable program or batch file.
'pnpm' is not recognized as an internal or external command,
operable program or batch file.
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Available memory (MB): 32426
Available CPU cores: 12
Binaries:
Node: 20.11.1
npm: 10.2.4
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 15.4.0-canary.34 // Latest available version is detected (15.4.0-canary.34).
eslint-config-next: N/A
react: 19.1.0
react-dom: 19.1.0
typescript: 5.8.3
Next.js Config:
output: standaloneWhich area(s) are affected? (Select all that apply)
Middleware
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local), Other (Deployed)
Additional context
For issue pathname being altered, the root cause is because REGEX_LOCALHOST_HOSTNAME is incorrect.
ayushman1413, maybe-dog and zachingle-easygo
Metadata
Metadata
Assignees
Labels
MiddlewareRelated to Next.js Middleware.Related to Next.js Middleware.
