-
-
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
HMR clientPort option ignored in normal mode #3737
Comments
this is important, without this it's impossible to run vite behind an https proxy, I had to workaround this by patching client.js: const socket = new WebSocket(`wss://my-host/myapp`, 'vite-hmr'); |
Hmmm, for some reason, using Nginx config: server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name (...);
ssl_certificate (...);
ssl_certificate_key (...);
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
location /admin {
proxy_pass http://vite_server:3000;
}
} Vite config: export default defineConfig({
plugins: [vue()],
base: '/admin/',
server: {
host: true,
port: 3000,
strictPort: true,
hmr: {
port: 443,
}
}
}) Also, on my local dev machine Vite dev server throws an error when |
Okay, if I understand the code correctly, in standard, non-middleware mode, there is no separate server for HMR created (until you specially create it and specify in vite/packages/vite/src/node/server/ws.ts Lines 26 to 38 in 24178b0
And here you can see that the vite/packages/vite/src/node/plugins/clientInjections.ts Lines 27 to 34 in 7db69a3
For the middleware mode, To summarizeIn non-middleware mode the It looks like there can be confusion with such fuzzy usage of options, and some unification would be fine. |
@Cretezy Great, it works! Thank you! |
Thanks for fixing, when I added that I didn't really know what |
Describe the bug
When using Vite behind a proxy, it would be nice to set the client port. I had it working when using SvelteKit, but I decide Vite alone would be more appropriate for my SPA. Found that the same
server.hmr
configuration didn't work. It appears thatclientPort
is only considered if in middleware mode.Reproduction
System Info
The text was updated successfully, but these errors were encountered: