From 9e659eb854848aee07fddc25f1d8f6c21facc7d8 Mon Sep 17 00:00:00 2001 From: omattsson Date: Sun, 15 Mar 2026 10:10:08 +0100 Subject: [PATCH] feat: configure Vite proxy and Nginx for WebSocket traffic (#8) - Add /ws proxy entry in vite.config.ts with ws: true (dev) - Add location /ws block in nginx.conf with upgrade headers and proxy_read_timeout 86400s (production) - Fix pre-existing wrong port 8080 -> 8081 for /api proxy in both files Refs #8 --- frontend/nginx.conf | 13 ++++++++++++- frontend/vite.config.ts | 6 +++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 762301b..a5470c5 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -10,11 +10,22 @@ server { # Proxy API requests to the backend location /api/ { - proxy_pass http://backend:8080/; + proxy_pass http://backend:8081/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } + + # Proxy WebSocket connections + location /ws { + proxy_pass http://backend:8081; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + proxy_read_timeout 86400s; + } } diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 299ba31..0e7f3e5 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -15,9 +15,13 @@ export default defineConfig({ host: true, proxy: { '/api': { - target: 'http://backend:8080', + target: 'http://backend:8081', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, '') + }, + '/ws': { + target: 'http://backend:8081', + ws: true } } }