fix(web): support LAN development access

This commit is contained in:
langbot-dev
2026-08-14 17:29:21 +08:00
parent b0566f4c9d
commit 7c387f75e1
2 changed files with 35 additions and 14 deletions
+5 -1
View File
@@ -1 +1,5 @@
VITE_API_BASE_URL=http://localhost:5300 # Leave empty in development to use Vite's same-origin proxy. This keeps API,
# login, and WebSocket requests working when the UI is opened from another
# device on the local network.
VITE_API_BASE_URL=
VITE_API_PROXY_TARGET=http://127.0.0.1:5300
+19 -2
View File
@@ -1,8 +1,12 @@
import { defineConfig } from 'vite'; import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
import path from 'path'; import path from 'path';
export default defineConfig({ export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const apiProxyTarget = env.VITE_API_PROXY_TARGET || 'http://127.0.0.1:5300';
return {
plugins: [react()], plugins: [react()],
resolve: { resolve: {
alias: { alias: {
@@ -10,9 +14,22 @@ export default defineConfig({
}, },
}, },
server: { server: {
host: '0.0.0.0',
port: 3000, port: 3000,
proxy: {
'/api': {
target: apiProxyTarget,
changeOrigin: true,
ws: true,
},
'/mcp': {
target: apiProxyTarget,
changeOrigin: true,
},
},
}, },
build: { build: {
outDir: 'dist', outDir: 'dist',
}, },
};
}); });