-
Notifications
You must be signed in to change notification settings - Fork 122
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
Configure vite HMR host from vite.json development.host #119
Conversation
Hi Grzesiek! Thanks for your contribution! I'll make some adjustments to ensure the |
Released in |
Thanks! |
@ElMassimo, Is it possible to document this somewhere. I had a slightly different but related problem. I ended up digging through the code to find this change. I think this will always use the Vite Ruby host config. So the problem I had was with a docker configuration. With In the end, I had to add this to {
server {
hmr: {
host: undefined,
}
}
} This may be worth mentioning somewhere to save someone else trouble. |
@RichGuk A docker setup like the one you describe might be more common than testing apps locally using subdomains, and is potentially harder to debug. I'm considering reverting this change, which would require explicit configuration of {
server {
hmr: {
host: 'localhost',
}
}
} We could then add a section in Troubleshooting that suggests this configuration when testing subdomains, which should make it easy to find. |
Hi, I was setting Vite in a new project using docker (so @ElMassimo I agree with your previous comment, because I think that this change breaks the more simple or common setups. @RichGuk thanks for take the time to post a comment with your findings. EDIT: and thanks for this nice gem! |
@grk Reverting this change, since Docker setups are more common than testing subdomains locally. I might release it in a patch version, since it doesn't affect production usage, and will add a note in the Troubleshooting section about subdomains. Please leave any feedback you have around this issue. |
@RichGuk @rbngzlv Released This should simplify the setup with Docker and similar setups that require listening on |
@ElMassimo upgraded a project from 2.x to 3.0.8 and worked fine, thanks! |
@ElMassimo without action cable in rails application is it possible to run HMR |
@ElMassimo its throws below error |
@uzaif313 That's unrelated to this issue, please open a Discussion instead. You need to configure CSP in your application. |
Description 📖
Adjust vite configuration to set HMR host and port.
Background 📜
When running an app that uses multiple subdomains, I was running into an issue where I wanted to run vite listening on localhost, and having app loaded from sub1.app.test and sub2.app.test use vite HMR at localhost:3036. I configured development.host in vite.json which correctly set
ViteRuby.config.host_with_port
tolocalhost:3036
, but vite client in the browser was trying to connect tosub1.app.test:3036
, violating CSP.The Fix 🔨
This change configures the vite client to use the same HMR config as what we're setting on the server side.
Screenshots 📷