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
This affects the dev server working behind an nginx reverse proxy. My most recent install of create-react-app has broken HMR/fast refresh which has previously been on other test projects I have set up in the same environment accessing my server through an ngninx proxy to re-route client requests to a port defined in my project .env file. nginx.config and env files are supplied below. The browser is repeatedly making requests to the server as wss://my-url:port/ws. I dont think React should be exposing the port to the client and I cant find anyway to override it using .env file settings.
I have reverted to a recent working package.json file and i suspect there is some recent modification that has broken fast refresh/module reload for proxied sites.
I have detailed a package.json for the broken install and a working package.json for side-by-side comparison. To test if this was a problem with the environment or other settings i removed the broken (latest) package.json and replaced with a working version and fast refresh works just fine so it has to be an issue with a change to package.json which i hope can be identified from the package.json comparison.
To reproduce this bug entirely requires a reverse proxied server with nginx configured AND access to code which i cant provide so i have supplied as much info as possible in the hope its possible to recreate.
(Write your answer here.)
Did you try recovering your dependencies?
yes i deleted node_modules and reinstalled and then i resorted to a last know working package.json file which works as expected.
i rebuilt the node_modules using the corrupted (latest) package.json and the problem persist.
Which terms did you search for in User Guide?
I have been searching all over the internet for related problems and none of them resolves the issue other than replacing package.json with a last know working installation and rebuilding node_modules.
(Write your answer here if relevant.)
Environment
sorry this is not useful but this is my systems reply to the npx command
bash-5.1# npx create-react-app --info
Need to install the following packages:
create-react-app
Ok to proceed? (y)
Steps to reproduce
(Write your steps here:)
install using package.json.1
add .env file to project. see below
configure nginx using proxy to redirect to port in env file. see below
run npm start and observe a steady stream of websocket errors in the browser (see image 1)
delete node_modules and replace package.json.1 with package.json.2
run npm start and observe that fast refresh is working correctly in the browser
The tool behaves correctly when i build the project with package.json.2 without changing any other part of the project
Actual behavior
The react app generates a steady stream of websocket connection errors when i use package.json.1. See screenshots below. It works if I rebuilt the project using package.json.2
(Write what happened. Please add screenshots!)
screenshot showing websocket errors in browser using package.json.1
note the reference to the port specified in the .env file
screenshot showing correct network operation using package.json.2
note the env file remains the same but the browser is not making explicit reference to server ports.
Reproducible demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
The text was updated successfully, but these errors were encountered:
I found a workaround for a similar issue in #11897 (comment), does it resolve the problem for you?
laurencefass
changed the title
Latest CRA installation is generating stream of websocket errors if i specify a PORT in .env file.
Latest CRA dev server issue. Browser is appending :port i specify in .env file.
Jan 9, 2022
laurencefass
changed the title
Latest CRA dev server issue. Browser is appending :port i specify in .env file.
Latest CRA dev server issue. Browser is appending :port specified in .env file.
Jan 10, 2022
Describe the bug
This affects the dev server working behind an nginx reverse proxy. My most recent install of create-react-app has broken HMR/fast refresh which has previously been on other test projects I have set up in the same environment accessing my server through an ngninx proxy to re-route client requests to a port defined in my project .env file. nginx.config and env files are supplied below. The browser is repeatedly making requests to the server as wss://my-url:port/ws. I dont think React should be exposing the port to the client and I cant find anyway to override it using .env file settings.
I have reverted to a recent working package.json file and i suspect there is some recent modification that has broken fast refresh/module reload for proxied sites.
I have detailed a package.json for the broken install and a working package.json for side-by-side comparison. To test if this was a problem with the environment or other settings i removed the broken (latest) package.json and replaced with a working version and fast refresh works just fine so it has to be an issue with a change to package.json which i hope can be identified from the package.json comparison.
To reproduce this bug entirely requires a reverse proxied server with nginx configured AND access to code which i cant provide so i have supplied as much info as possible in the hope its possible to recreate.
(Write your answer here.)
Did you try recovering your dependencies?
yes i deleted node_modules and reinstalled and then i resorted to a last know working package.json file which works as expected.
i rebuilt the node_modules using the corrupted (latest) package.json and the problem persist.
Which terms did you search for in User Guide?
I have been searching all over the internet for related problems and none of them resolves the issue other than replacing package.json with a last know working installation and rebuilding node_modules.
(Write your answer here if relevant.)
Environment
sorry this is not useful but this is my systems reply to the npx command
bash-5.1# npx create-react-app --info
Need to install the following packages:
create-react-app
Ok to proceed? (y)
Steps to reproduce
(Write your steps here:)
.env file
nginx proxy configuration
package.json.1 from most recent installation (results in broken websockets - see screenshot below)
package.json.2 (correct operation - see screenshot below)
Expected behavior
The tool behaves correctly when i build the project with package.json.2 without changing any other part of the project
Actual behavior
The react app generates a steady stream of websocket connection errors when i use package.json.1. See screenshots below. It works if I rebuilt the project using package.json.2
(Write what happened. Please add screenshots!)
screenshot showing websocket errors in browser using package.json.1
note the reference to the port specified in the .env file
screenshot showing correct network operation using package.json.2
note the env file remains the same but the browser is not making explicit reference to server ports.
Reproducible demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
The text was updated successfully, but these errors were encountered: