Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Allow a dev-proxy Origin override for secondary Vite instances

rcourtman58aa00c5c454
diff --git a/frontend-modern/vite.config.ts b/frontend-modern/vite.config.ts
index 42956570e6..2ab1d1b168 100644
--- a/frontend-modern/vite.config.ts
+++ b/frontend-modern/vite.config.ts
@@ -36,6 +36,13 @@ const backendWsUrl =
}
})();
+// When the dev server runs on a non-default port (e.g. a preview/tooling
+// instance beside the managed 5173 one), the backend's dev origin allowlist
+// (http://localhost:5173,http://localhost:7655) rejects WebSocket upgrades.
+// Setting PULSE_DEV_PROXY_ORIGIN rewrites the proxied Origin header to an
+// allowed one. Unset, nothing changes.
+const proxyOriginOverride = process.env.PULSE_DEV_PROXY_ORIGIN ?? '';
+
const srcAlias = path.resolve(__dirname, './src');
export default defineConfig({
@@ -63,6 +70,7 @@ export default defineConfig({
proxy.options.proxyTimeout = 0;
proxy.on('proxyReqWs', (proxyReq, req, socket) => {
+ if (proxyOriginOverride) proxyReq.setHeader('Origin', proxyOriginOverride);
socket.setTimeout(0);
socket.setNoDelay(true);
socket.setKeepAlive(true, 30000);