-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
feat(dev): add config for websocket connection #677
Conversation
Why do not get HMR websocket address and port from browser location by default? In my case, it's make me hardcode external address instead of just specify unix socket and go... |
Yeah.If you not config |
May be i misunderstand something, but i talk in context of my issue #674 If i specify server listening socket as port (it's work because node support that), it's replace client port, and i can prevent it only hardcode valid port with socketPort. I think it's don't close my issue. I think best way add socket opt especially for server listening like webpack.
and
|
Any updates on this? This seems to be exactly what I need. I have nginx as a reverse proxy to use domain names (https://somedomain.me). This PR would allow me to easily specify a different websocket location. (By default it now goes to https://somedomain.me:5001 which would need annoying nginx configuration for the websocket to go through). |
@underfin Sorry to bother you about this again. This seems to be something that should be available to anyone. Do you happen to know a reason why this is not merged into master? The reason I'm asking is because I need #833 as well. I'm willing to contribute but it almost looks as if some major refactor is on its way that either solves all my problems / would be incompatible with my efforts. Thanks for your time. |
@knightly-bot build this |
🌒 Knightly build enabled, release every night at 00:00 UTC (skip if no change) |
We will have a closer look to see if it's ready to be merged next week. Before that, I have requested a build for you and you can opt-in and try it in your app now. That would be great if you could have some feedback on this. Thanks. |
@antfu Thanks for getting back to me. I tried the knightly build, and it is almost what I need. @underfin When using this with for example If we were able to specify the protocol to use as well, that would be great:
|
@CantGetRight82 I refacot code. New option is here.
|
Do you succeed to proxy vite behind nginx? |
I do succeed to proxy but not without additional nginx config:
And then in vite.config.js:
Best of luck! |
@ebeloded Here's the configuration I've used in case it's useful: const codespaceName = process.env['CODESPACE_NAME'];
const hmrPort = 24678;
const hmrRemoteHost = codespaceName ? `${codespaceName}-${hmrPort}.githubpreview.dev` : 'localhost';
const hmrRemotePort = codespaceName ? 443 : hmrPort;
// then in the config...
hmr: {
host: hmrRemoteHost,
port: hmrPort,
clientPort: hmrRemotePort
} |
I know this isn't the best place for this discussion but this is first result on Google. Thanks @mbarton as this works! I found I had to go to |
I'm getting a simple text response "Upgrade Required" when I try doing this. I added @mbarton code to my Vite config with no success (in the context of SvelteKit). I can make changes and refresh the page to get updated results just fine when I use the regular preview url at |
@jacobbowdoin and @TomCaserta please open a new issue with a reproduction if you experience problems with websocket connection. this pull request was for vite version 1 |
Thanks.By the way, you need to specify port using
|
vite.config.js
package.json
Last step is to set |
close #674, close #676, close #652