Hi,
I’m using sveltekit and vite and caddyv2, love caddy!
But I’m having problem proxying websocket, so the condition is like this :
- sveltekit with vite → npm run dev → it listens to localhost:3000, there’s hmr that using websocket
- then I’m using https:\example.com to proxy to localhost, and here’s my caddy.json
{
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":443"
],
"routes": [
{
"match": [
{
"host": [
"example.com"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "localhost:4000"
}
]
}
],
"match": [
{
"header": {
"Connection": [
"*Upgrade*"
],
"Upgrade": [
"websocket"
]
}
}
]
},
{
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "localhost:3000"
}
]
}
]
}
]
}
]
}
]
}
}
}
}
}
As we can see above, I already use upgrade for websocket, that forward to localhost:4000
here’s vite config
vite: {
...
server: {
hmr: {
protocol: 'wss',
port:4000
}
},
}
But it seems websocket is not proxied to hmr server, when I look @chrome dev tools, it always display pending
What did I do wrong ?
Thanks Websocket question
Edit: Using preformatted text Help : Websocket question