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
+30 -13
View File
@@ -1,18 +1,35 @@
import { defineConfig } from 'vite';
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
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()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
},
server: {
port: 3000,
},
build: {
outDir: 'dist',
},
server: {
host: '0.0.0.0',
port: 3000,
proxy: {
'/api': {
target: apiProxyTarget,
changeOrigin: true,
ws: true,
},
'/mcp': {
target: apiProxyTarget,
changeOrigin: true,
},
},
},
build: {
outDir: 'dist',
},
};
});