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:
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user