Open marcoippolito opened 4 years ago
Thanks for all these details, but taking a step back I would like a clear description for the problem
I'm not very good with nginx but it seems some config is wrong or missing and so the websocket connection is not passed through correctly.
I don't see how we can fix this from within Vue CLI, but I may be wrong/missing something
@LinusBorg I stopped nginx server, and executed npm run serve:
(base) marco@pc:~/vueMatters/testproject$ sudo systemctl stop nginx
[sudo] password for marco:
(base) marco@pc:~/vueMatters/testproject$ sudo systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sun 2020-02-02 09:58:36 CET; 6s ago
Docs: man:nginx(8)
Process: 4359 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile
/run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 983 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited,
status=0/SUCCESS)
Process: 872 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited,
status=0/SUCCESS)
Main PID: 1001 (code=exited, status=0/SUCCESS)
Feb 02 09:18:32 pc systemd[1]: Starting A high performance web server and a reverse proxy
server...
Feb 02 09:18:33 pc systemd[1]: Started A high performance web server and a reverse proxy
server.
Feb 02 09:58:36 pc systemd[1]: Stopping A high performance web server and a reverse proxy
server...
Feb 02 09:58:36 pc systemd[1]: Stopped A high performance web server and a reverse proxy
server.
(base) marco@pc:~/vueMatters/testproject$ npm run serve
> testproject@0.1.0 serve /home/marco/vueMatters/testproject
> vue-cli-service serve
INFO Starting development server...
98% after emitting CopyPlugin
DONE Compiled successfully in 986ms
9:58:54 AM
App running at:
- Local: http://localhost:8080
- Network: http://192.168.1.7:8080
Note that the development build is not optimized.
To create a production build, run npm run build.
But still in Google Chrome get the error: "GET http://localhost:8080/sockjs-node/info?t=1580634002894
net::ERR_CONNECTION_REFUSED" :
And in FireFox the error: "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8080/sockjs-node/info?t=1580634450627. (Reason: CORS request did not succeed)."
Add-ons installed in Google Chrome:
Add-ons installed in Firefox:
@LinusBorg In the PC I installed ex-novo Ubuntu 18.04.3 Desktop and I verified that the problem disappeared.
I ran the same tiny webapp in both laptop and pc, and using localhost and the ip-address both from within the laptop/PC and from the other device (PC/laptop) gave no error. I reported everything here https://askubuntu.com/questions/1207812/webapp-fails-with-neterr-connection-refused-with-ubuntu-18-04-4-server-edition
According to you, what kind of problems/missing parts/lacking features or whatever the Ubuntu 18.04.4 Server Edition could have compared to the Ubuntu 18.04.4 Desktop Edition? It would be great if we could give to the Ubuntu's people some hints/suggestions and help in solving this problem.
I'm getting this too, and while the easy fix is to remove the https config and just use http, it would be nice to find out how to set this up correctly. I think there's an interesting clue in @marcoippolito 's screenshot:
Notice that the browser address bar is using an IP address, while the script that webpack devServer injects is trying to open a socket to localhost -- this makes it a cross-domain request, which fails because the dev/hmr server isn't producing CORS headers. Curiously in my instance I'm visiting localhost and the injected script is trying to open the IP address: the same problem in reverse.
(Update: I should note that I'm using mkcert
to create a TLS certificate for localhost
, and that's not valid for the local IP address, which might also explain why there's a CORS error. If I visit the IP address instead of localhost, then click through the certificate error, everything works).
The problem is that you’re browsing to http://192.168.1.7
(or whatever IP) while the Webpack Dev Server client attempts to connect to http://localhost
, which is a different origin.
The solution is for Webpack Dev Server to use a relative URI when connecting.
The problem is here:
The code should be using 0.0.0.0:0
, like angular does:
This would also enable use cases like proxying to the dev server from elsewhere.
Version
4.1.2
Reproduction link
https://github.com/marcoippolito/testproject
Environment info
Steps to reproduce
I created a brand new tiny webapp with vue cli, so without adding anything, apart from what the empty vue-cli scaffolding brings:
And get this error message : https://drive.google.com/open?id=10GcVFmqNVGRjox3wklJtcrAkIWM3kOp8
Using firefox as web browser, I get this error message: https://drive.google.com/open?id=1l6USIHrbHl6kBcQtormXplOgx0J653ko
Looking at Mozilla Developer explanation: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSDidNotSucceed?utm_source=devtools&utm_medium=firefox-cors-errors&utm_campaign=default
"
In order to understand where the problem could lie, I checked various aspects:
Checked the TLS Certificates with https://www.digicert.com/help/ : and the result is: " TLS Certificate has not been revoked. TLS Certificate expires soon. The primary TLS Certificate expires on February 28, 2020 (30 days remaining) Certificate Name matches ggc.world TLS Certificate is correctly installed "
curled the url both from within the PC-Server, and from a laptop:
-From within the PC-Server:
(base) marco@pc:~$ curl -Iki https://localhost/sockjs-node/info?t=1580397983088 HTTP/2 405 server: nginx/1.14.0 (Ubuntu) date: Fri, 31 Jan 2020 08:19:02 GMT allow: OPTIONS, GET
(base) marco@pc:~/vueMatters/testproject$ curl -vk https://localhost/sockjs- node/info?t=1580397983088
-From a laptop:
(base) marco@marco-U36SG:~$ curl -Iki https://ggc.world/sockjs-node/info?t=1580397983088 HTTP/1.1 405 Method Not Allowed Server: nginx/1.14.0 (Ubuntu) Date: Fri, 31 Jan 2020 09:34:59 GMT Connection: keep-alive Allow: OPTIONS, GET
(base) marco@marco-U36SG:~$ curl -vk https://ggc.world/sockjs-node/info?t=1580397983088
TLSv1.3 (OUT), TLS handshake, Client hello (1): TLSv1.3 (IN), TLS handshake, Server hello (2): TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8): TLSv1.3 (IN), TLS handshake, Certificate (11): TLSv1.3 (IN), TLS handshake, CERT verify (15): TLSv1.3 (IN), TLS handshake, Finished (20): TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1): TLSv1.3 (OUT), TLS handshake, Finished (20): SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 ALPN, server accepted to use http/1.1 Server certificate: subject: CN=ggc.world start date: Nov 30 11:22:10 2019 GMT expire date: Feb 28 11:22:10 2020 GMT issuer: C=US; O=Let’s Encrypt; CN=Let’s Encrypt Authority X3 SSL certificate verify ok.
This is the output of the "Network" tab : https://drive.google.com/open?id=1QJMe8FEBrEuWacHWeJ_TQegMkF0v68AY
This is the "view source" of the html page:
<!DOCTYPE html>
This is the result of the "localhost" word search in app.js:
https://drive.google.com/open?id=11QpJKjd4PLKNMnO7m2utCJ9PrzO8Oyji :
/*!****!*\ ! multi (webpack)-dev-server/client?http://localhost (webpack)/hot/dev-server.js (webpack)- dev-server/client?http://192.168.1.7:8080/sockjs-node ./src/main.js ! ******/ /! no static exports found / /*/ (function(module, exports, __webpack_require__) {
server/client
/index.js?http://localhost /"./node_modules/webpack-dev-server/client/index.js?http: //localhost"); __webpack_require__(/! /home/marco/vueMatters/testproject/node_modules/webpack /hot/dev-server.js
/"./node_modules/webpack/hot/dev-server.js"); __webpack_require__(/! /home/marco/vueMatters/testproject/node_modules/webpack-dev- server/client /index.js?http://192.168.1.7:8080/sockjs-node /"./node_modules/webpack-dev-server/client /index.js?http:
//192.168.1.7:8080/sockjs-node"); module.exports = __webpack_require__(/! ./src/main.js */"./src/main.js"); /*/ }) /****/ });
These are the results of the "localhost" word search in chunk-vendors.js :
In this GitHub repository you can find all the related files: https://github.com/marcoippolito/testproject
The sudo nano /etc/nginx/conf.d/default.conf is the following:
draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:! MD5; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:50m; ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_stapling on;
What is expected?
no ERR_CONNECTION
What is actually happening?
I opened an issue in webpack's github page: https://github.com/webpack/webpack/issues/10329 , and it has been closed with this reason "Please open issue in vue-cli". Please look also at the detailed description of the problem I made there. Looking forward to a joint effort and help