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.
This commit is contained in:
Steven RYDELL
2026-07-29 05:48:07 +02:00
parent a83e75a79f
commit 4739f9ed92
+8
View File
@@ -16,6 +16,14 @@ export default defineConfig({
'@': path.resolve(__dirname, './src'), '@': 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: { test: {
globals: false, globals: false,
environment: 'happy-dom', environment: 'happy-dom',