Anybody Have a Cloudflare Tunnel Working with Rspack HMR? [SOLVED]

Does anybody have a Cloudflare Tunnel working with rspack HMR yet?

If so could you please post your Cloudflare config and the devServer part of your rspack config?
I’ve been hammering on this for days and haven’t gotten it working yet.

In case anybody can just see from looking what’s wrong with my config, here it is:

Cloudflare Config

ingress:
  # WebSocket routes (must come first due to path specificity)
  - hostname: www.myDevDomain.com
    path: /ws
    service: ws://localhost:8080
  - hostname: myDevDomain.com
    path: /ws
    service: ws://localhost:8080
  - hostname: wss.myDevDomain.com
    path: /ws
    service: ws://localhost:8080
  
    # HTTP routes
  - hostname: myDevDomain.com
    service: http://localhost:3000
  - hostname: www.myDevDomain.com
    service: http://localhost:3000
  
  # Catch-all
  - service: http_status:404

rspack Config

       devServer: {
            port: 8080,
            host: '0.0.0.0',
            allowedHosts: 'all',
            hot: true,

            client: {
                overlay: true,
                reconnect: 3,
                webSocketURL: {
                    protocol: 'ws',
                    hostname: 'localhost',
                    port: 8080,
                    pathname: '/ws',
                },
            },
        },

Update

Hmmm… Grok says :

YOU ARE 99% THERE — BUT YOU’RE RUNNING A DEV SERVER IN PRODUCTION


The Problem (in plain English)

You’re seeing:

text

GET https://www.myDevDomain.com/rspack/main.876de1f01b0e1953.hot-update.json 404 (Not Found)
[HMR] Cannot find update. Need to do a full reload!

This means:

Your frontend is trying to do “Hot Module Replacement” (HMR) over the internet — but the dev server files (*.hot-update.json) only exist on localhost


Why This Happens

Part What’s Happening
ws://localhost:8080/ws Your dev server (Vite, Webpack, Rspack)
wss://www.myDevDomain.com/ws Cloudflare tunnels to that dev server
https://www.myDevDomain.com/rspack/...hot-update.json Browser tries to fetch HMR assets from public domain
404 Those files don’t exist publicly — they’re only served on localhost

The Fix: STOP USING DEV SERVER IN PRODUCTION

You cannot use npm run dev behind Cloudflare Tunnel in production.

<<<<<<<<<

That seems to make sense.

1 Like