diff --git a/webapp/vite.config.ts b/webapp/vite.config.ts index 51f9500a18..a4667f0991 100644 --- a/webapp/vite.config.ts +++ b/webapp/vite.config.ts @@ -1,29 +1,28 @@ -import { defineConfig } from "vite"; +import { type ProxyOptions, defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; const SERVER_URL = "http://localhost:8080"; +const proxyOptions: ProxyOptions = { + target: SERVER_URL, + changeOrigin: true, // Recommended for avoiding CORS issues + ws: true, // WebSocket support for hot module replacement +}; + // https://vitejs.dev/config/ export default defineConfig(({ mode }) => { const isDesktopMode = mode === "desktop"; return { - // When the web application is running in Desktop mode, - // the web app is served at the `/static` entry point + // Serve the web app at the `/static` entry point on Desktop mode base: isDesktopMode ? "/static/" : "/", plugins: [react({ devTarget: "es2022" })], server: { port: 3000, strictPort: true, proxy: { - // Main API URLs - "/v1": SERVER_URL, - // Core API URLs - "/health": SERVER_URL, - "/kill": SERVER_URL, - "/version": SERVER_URL, - // WebSocket - "/ws": SERVER_URL, + // API, WebSocket and Swagger URLs + "^/(v1|health|kill|version|ws|openapi.json|redoc)": proxyOptions, }, }, };