Use different API route according the ENV (#13597)

### What problem does this PR solve?

1. Fix go server date precision
2. Use API_SCHEME_PROXY to control the web API route

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-03-13 19:05:30 +08:00
committed by GitHub
parent 1569ed82f8
commit cc7e94ffb6
14 changed files with 140 additions and 73 deletions

View File

@@ -30,6 +30,83 @@ const inspectorBabelPlugin = (): import('vite').Plugin => ({
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const proxySchemes = {
python: {
'/api/v1/admin': {
target: 'http://127.0.0.1:9381/',
changeOrigin: true,
ws: true,
},
'/api': {
target: 'http://127.0.0.1:9380/',
changeOrigin: true,
ws: true,
},
'/v1': {
target: 'http://127.0.0.1:9380/',
changeOrigin: true,
ws: true,
},
},
hybrid: {
'/v1/system/config': {
target: 'http://127.0.0.1:9384/',
changeOrigin: true,
ws: true,
},
'/v1/user/login': {
target: 'http://127.0.0.1:9384/',
changeOrigin: true,
ws: true,
},
'/v1/user/logout': {
target: 'http://127.0.0.1:9384/',
changeOrigin: true,
ws: true,
},
'/api/v1/admin/sandbox': {
target: 'http://127.0.0.1:9381/',
changeOrigin: true,
ws: true,
},
'/api/v1/admin': {
target: 'http://127.0.0.1:9385/',
changeOrigin: true,
ws: true,
},
'/api': {
target: 'http://127.0.0.1:9380/',
changeOrigin: true,
ws: true,
},
'/v1': {
target: 'http://127.0.0.1:9380/',
changeOrigin: true,
ws: true,
},
},
go: {
'/api/v1/admin': {
target: 'http://127.0.0.1:9385/',
changeOrigin: true,
ws: true,
},
'/api': {
target: 'http://127.0.0.1:9384/',
changeOrigin: true,
ws: true,
},
'/v1': {
target: 'http://127.0.0.1:9384/',
changeOrigin: true,
ws: true,
},
},
};
const proxy =
proxySchemes[env.API_PROXY_SCHEME || 'python'] || proxySchemes.python;
return {
plugins: [
inspectorBabelPlugin(),
@@ -85,38 +162,7 @@ export default defineConfig(({ mode }) => {
hmr: {
overlay: false,
},
proxy: {
'/api/v1/admin': {
target: 'http://127.0.0.1:9381/',
changeOrigin: true,
ws: true,
},
'/api': {
target: 'http://127.0.0.1:9380/',
changeOrigin: true,
ws: true,
},
// '/v1/system/config': {
// target: 'http://127.0.0.1:9382/',
// changeOrigin: true,
// ws: true,
// },
// '/v1/user/login': {
// target: 'http://127.0.0.1:9382/',
// changeOrigin: true,
// ws: true,
// },
// '/v1/user/logout': {
// target: 'http://127.0.0.1:9382/',
// changeOrigin: true,
// ws: true,
// },
'/v1': {
target: 'http://127.0.0.1:9380/',
changeOrigin: true,
ws: true,
},
},
proxy,
},
assetsInclude: ['**/*.md'],
base: env.VITE_BASE_URL,