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

Feature request: add options to use location.port for hmr connection. #5366

Closed
4 tasks done
lcjnil opened this issue Oct 21, 2021 · 3 comments
Closed
4 tasks done

Feature request: add options to use location.port for hmr connection. #5366

lcjnil opened this issue Oct 21, 2021 · 3 comments

Comments

@lcjnil
Copy link

lcjnil commented Oct 21, 2021

Clear and concise description of the problem

We use vite dev server locally and behind proxy, for example, we start vite at localhost:8080, we want to access it via http://localhost:8080 or we use local proxy (caddy, nginx, whistle...) to access via some domain(like http://local.dev.app).

But currently, vite's hmr options is not working for our scenario. Vite can only configure hmr's websocket port to one specific port, which means we can't let it connect in ws://localhost:8080 when access via http://localhost:8080 and connect in ws://local.dev.app via http://local.dev.app.

And we cannot find any way to edit it dynamicly.

The code is https://github.com/vitejs/vite/blob/v2.6.9/packages/vite/src/node/plugins/clientInjections.ts#L26-L34

Suggested solution

We can add an option to enforce hmr connection use location.port, like server.hmr.useLocationPort.

Alternative

No response

Additional context

No response

Validations

@malobre
Copy link

malobre commented Nov 24, 2021

I use a similar setup (caddy proxy) to try and make the development environment as similar to production as possible (w.r.t https, CORS, subdomains, etc).
This would be a very useful feature.

@malobre
Copy link

malobre commented Nov 27, 2021

This seems to be a duplicate of #3093

@Niputi
Copy link
Contributor

Niputi commented Nov 27, 2021

duplicate of #3093

@Niputi Niputi closed this as completed Nov 27, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants