Websocket host/port for HMR uses the window.location variables instead of actual configured values in the server #54158
Labels
bug
Issue was opened via the bug report template.
create-next-app
Related to our CLI tool for quickly starting a new Next.js application.
stale
The issue has not seen recent activity.
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 Binaries: Node: 18.17.1 npm: 9.6.7 Yarn: 1.22.19 pnpm: N/A Relevant Packages: next: 13.4.17-canary.1 eslint-config-next: 13.4.13 react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.6 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
CLI (create-next-app)
Link to the code that reproduces this issue or a replay of the bug
https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/react-dev-overlay/internal/helpers/get-socket-url.ts#L13
To Reproduce
Describe the Bug
When a NextJS app is under an HTTP proxy, the WebSocket connection is not established since the client code looks for the connection with port
window.location.port
instead of the WebSocket configured port.For example, I have a web proxy in http://localhost:8080 to forward the connection to http://localhost:3000.
NextJS run in http://localhost:3000.
In this case, the WebSocket client connects with URL:
ws://localhost:8080/
but it should bews://localhost:3000/
https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/react-dev-overlay/internal/helpers/get-socket-url.ts#L13
Expected Behavior
Please use the configured host/port to establish the WebSocket connection instead of using
window.location
variables.Which browser are you using? (if relevant)
Chrome
How are you deploying your application? (if relevant)
yarn dev
The text was updated successfully, but these errors were encountered: