#[HMR, Vite + Apache] HMR stopped working after v4.3.9

1 messages · Page 1 of 1 (latest)

patent mist
#

Why I don't have a minimal repro

This project uses an Apache server and I'm just not sure how I would be able to reproduce that. My hope is that someone will know what happened in between v4.3.9 and v4.4.0 that made HMR stop working for me.

Reproduction steps:

  • Start Apache server
  • Start Vite server
  • Open Vite app in browser through Apache
  • Make a change in a file
  • Nothing happens in browser

Context

I upgraded from v4.3.9. I've tried all versions from v.4.4.0 all the way up to v.4.5.0.

Problem

HMR stopped working. I can tell in the terminal that Vite registeres that my file has been changed and triggers a page reload, ex:

10:38:44 [vite] page reload index.html
10:38:45 [vite] page reload index.html (x2)
10:39:39 [vite] page reload index.html (x3)
10:39:44 [vite] page reload index.html (x4)

My vite.config.ts looks like this:

export default defineConfig({
 ...
  base: "/dev/",
  server: {
    host: "thing.mywebsite.com",
    port: 5173,
    strictPort: true,
  },
})

In the browser I get this error message

console.js:213 [vite] failed to connect to websocket.
your current setup:
  (browser) thing.mywebsite.com/dev/ <--[HTTP]--> thing.mywebsite.com.se:5173/dev/ (server)
  (browser) thing.mywebsite.com:/dev/ <--[WebSocket (failing)]--> thing.mywebsite.com:5173/dev/ (server)

My Apache config looks like this:

ProxyPass       /dev    http://localhost:5173/dev
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule     /dev    ws://localhost:5173/$1 [P,L]

Let me know if there's more info I need to provide, not sure what happened between v4.3.9 and v.4.4.0 that changed the HMR behavior.

#

[HMR, Vite + Apache] HMR stopped working after v4.3.9