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

If i use nginx as proxy,this port is 80,react app's port 3000,webpackHotdev create websocket with port 80,and the error occur. #2591

Closed
cyssxt opened this issue Jun 22, 2017 · 4 comments

Comments

@cyssxt
Copy link

cyssxt commented Jun 22, 2017

Description

If i use nginx as proxy,nginx's port is 80,react app's port is 3000,webpackHotdev create websocket with port 80,and the error occur.

What are you reporting?
Can't react-scripts support proxy?

Tell us what you think should happen.

webpack-dev-server\client\index.js

 create html websocket client

var socketUrl = url.format({
protocol: protocol,
auth: urlParts.auth,
hostname: hostname,
port: (urlParts.port === '0') ? window.location.port : urlParts.port,
pathname: urlParts.path == null || urlParts.path === '/' ? "/sockjs-node" : urlParts.path
});
this port real value is 3000

webpackHotDevClient.js

  nodejs create webscoket server!

var connection = new SockJS(url.format({
protocol: window.location.protocol,
hostname: window.location.hostname,
port: window.location.port,
// Hardcoded in WebpackDevServer
pathname: '/sockjs-node'
}));
this port real value is 80
So we can't communicate through websocket ,while we use a proxy server !
I think if we want to resolve this bug ,we should add a config to set websocket port and host!

@cyssxt cyssxt changed the title If i use nginx as proxy,this port is 80,react app's port 3000,webpackHotdev If i use nginx as proxy,this port is 80,react app's port 3000,webpackHotdev create websocket with port 80,and the error occur. Jun 22, 2017
@Timer
Copy link
Contributor

Timer commented Jun 22, 2017

Hi! This is being implemented in #1588. Please watch it for updates. 😄

@Timer Timer closed this as completed Jun 22, 2017
@cyssxt
Copy link
Author

cyssxt commented Jun 24, 2017

yeah!Get it!Thanks!

@bharath063
Copy link

For future reference, you can also work around this by doing something along the lines of

location /sockjs-node/ {
	    proxy_pass http://localhost:3000;
            proxy_http_version 1.1;
	    proxy_set_header Upgrade $http_upgrade;
	    proxy_set_header Connection "upgrade";
	}

to your nginx config.

@sponia-joker
Copy link

@bharath063 It just what I need.thanks

@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants