From 4739f9ed923bc0fe66b6a5062b187cbe3f7d1241 Mon Sep 17 00:00:00 2001 From: Steven RYDELL Date: Wed, 29 Jul 2026 05:48:07 +0200 Subject: [PATCH] Proxy API and JMAP requests to a local Stalwart server in dev Same-origin proxying to localhost:8080 avoids CORS without weakening the server's CORS policy; pair with VITE_API_BASE_URL= (empty) in .env.development.local. --- vite.config.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vite.config.ts b/vite.config.ts index 89348f5..cbe722c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -16,6 +16,14 @@ export default defineConfig({ '@': path.resolve(__dirname, './src'), }, }, + server: { + // Same-origin proxy to the local Stalwart container: avoids CORS entirely + // (VITE_API_BASE_URL stays empty in .env.development.local). + proxy: { + '/api': { target: 'http://localhost:8080', changeOrigin: true, ws: true }, + '/jmap': { target: 'http://localhost:8080', changeOrigin: true, ws: true }, + }, + }, test: { globals: false, environment: 'happy-dom',