Development with https proxy + HMR (recipe) #181
zealot128
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
Thanks for sharing Stefan! Should be useful for folks using Caddy in a similar manner. Regarding the last point, it might be related to #179, which means it might require no config once that's reverted. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In Dev, we run the server proxied by a Caddy/Nginx, so that https works great, and we can easily guess the hostnames of each developer and the development systems are reachable from outside (WebHook-Test etc.).
Also, we are using one big shared machine for work, so the ports are automatically assigned for the rails-server and vite-server, and the Caddy sorts the traffic:
1. Proxy config:
This is an example of a Caddy-like config to proxy both the rails-server (Port 3000 in this example), and Vite (Port 3001 in this example)
For this to work, we are using the environment variables when running vite dev (in our setup we have a small wrapper that determines the port automatically by app-type+developer):
VITE_RUBY_PORT=3001 VITE_RUBY_HOST=0.0.0.0 VITE_RUBY_AUTO_BUILD=false VITE_RUBY_HTTPS=false ## this env is not used by Vite-Ruby, but in our config below VITE_WSS_HOST=realdomain.company.com
Also, then we still got errors in development regarding HMR, so we fixed it by setting the ws-host in die Vite-conf directely:
Otherwise, the HMR script that got injected will point to a wrong host, like "ws://localhost:3001", but we want it to be "wss://realdomain.company.com"
Beta Was this translation helpful? Give feedback.
All reactions