-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Websockets fail with HTTPS and http/2 if there is a reverse proxy on the line. #1653
Comments
Honestly I have no idea how to fix this, so PR welcome. |
I did some digging, and from what I am reading, I believe to use websockets with http2 in node, you'd have to use Refs: |
i dont know much about protocol but i got issue with same place |
It works perfectly in vue cli. It said:
But for the vite dev server, it totally ignores the port from URL, and uses port from the Would be nice to have similar behavior with vue cli. UPD this config helped with the issue:
|
Adding @xorik's code to |
This solved my reload problem behind haproxy in a docker node container. I'm using svelte.kit // "@sveltejs/adapter-node": "^1.0.0-next.51",
// "@sveltejs/kit": "^1.0.0-next.174",
// "svelte": "^3.43.0", |
Same problem for gitpod. Thanks a lot to @xorik, upd. Here is universal solution for gitpod: // vite.config.js
let hmr = true;
if (process.env.GITPOD_WORKSPACE_CONTEXT) {
hmr = {
host: `3000-${process.env.GITPOD_WORKSPACE_ID}.${process.env.GITPOD_WORKSPACE_CLUSTER_HOST}`,
port: 443,
protocol: "wss",
};
} |
I ran into the same problem that using the Whistle tool to reverse proxy an online address locally caused an infinite loop and HMR failure. If you fill in port:443, Vite will refresh indefinitely, but removing the port:443 will send the requests (https://xxx.net/...whistle-path.5b6af7b9884e1165...///whistle.bifrost/cgi-bin/list?_=1650621054028) every few seconds, then the page will refresh(the timestamp of the request parameter _ will change),and the HMR will be disabled when you save. here is my config:
|
Closing as #8650 fixed this. Please try 3.0.0-beta.1. |
ViteJS fails to upgrade to websockets when using HTTPS and http/2 and there is a reverse proxy between the server and the browser.
Reproduction
Create a new container and install a blank new ViteJS project.
Install a reverse proxy, and tell it to use your container, and a test domain. For example haproxy on rpm based systems:
Set
/etc/haproxy.cfg
to this minimal config:.. where 10.0.0.4 is the IP of your container with the vitejs instance.
certificate.pem
should be a certificate valid for a domain. Use this domain in/etc/hosts
to map to the ip of the haproxy server.Once it's all set up, open the domain in the browser. Vite will load, ... but then, it will go into an endelss loop trying to reconnect.
The broswer's inspector will have a message, its a bit hard to catch:
Logs
In chrome, observe:
In firefox:
Workaround
Use only http/1.1 - in haproxy, remove
alpn h2,http/1.1
on both sides.However, this might be not an option for people using hosting services.
System Info
vite
version: vite/2.0.0-beta.36The text was updated successfully, but these errors were encountered: