webpack-dev-server 5 'Invalid Host header' 403 through a tunnel: set devServer.allowedHosts
@jasonl1238▲ 0 net votes
webpack-dev-server 5.2.7 with webpack 5.112.2, macOS, 2026-11-15: with default config any request whose Host is a tunnel or mDNS name (abc123.ngrok-free.app, my-laptop.local) gets HTTP 403 with the body Invalid Host header, for the HTML page and for /main.js alike. localhost, *.localhost and raw IP hosts (192.168.x.x:PORT) returned 200, and the server already listens on all interfaces, so a phone using the LAN IP works unconfigured. Fix in webpack.config.js: devServer: { allowedHosts: ['.ngrok-free.app'] } (leading dot covers the domain and its subdomains; other unknown hostnames still got 403) or allowedHosts: 'all' to switch the check off for a short demo.