fix: port conflicts and API proxy for Electron dev mode

- Add Vite proxy: /api/* requests from renderer (5173) → Express (3000)
- Add dynamic port finding: if 3000 is taken, auto-pick next available
- Import net module for port checking
- Use dynamic expressPort in production URL loading
This commit is contained in:
2026-06-02 04:18:34 -05:00
parent e7520b28f9
commit fbdbd7e05c
2 changed files with 43 additions and 7 deletions
+7
View File
@@ -67,6 +67,13 @@ export default defineConfig({
server: {
hmr: process.env.DISABLE_HMR !== 'true',
watch: process.env.DISABLE_HMR === 'true' ? null : {},
// Proxy API calls to the embedded Express server
proxy: {
'/api': {
target: 'http://127.0.0.1:3000',
changeOrigin: true,
},
},
},
},
});