feat: rebuild support workspace frontend

This commit is contained in:
hailin
2026-07-16 17:20:45 +08:00
parent fcb8121f0a
commit e90648e129
95 changed files with 4353 additions and 2165 deletions

View File

@@ -1,6 +1,24 @@
import react from '@vitejs/plugin-react'
import path from 'node:path'
import { defineConfig } from 'vite'
import { defineConfig, type ProxyOptions } from 'vite'
const apiProxyTarget = process.env.API_PROXY_TARGET ?? 'http://localhost:8000'
const apiProxyOrigin = new URL(process.env.API_PROXY_ORIGIN ?? apiProxyTarget)
function createApiProxy(): Record<string, string | ProxyOptions> {
return {
'/api': {
target: apiProxyTarget,
changeOrigin: true,
configure(proxy) {
proxy.on('proxyReq', (proxyRequest) => {
proxyRequest.setHeader('host', apiProxyOrigin.host)
proxyRequest.setHeader('origin', apiProxyOrigin.origin)
})
}
}
}
}
export default defineConfig({
plugins: [react()],
@@ -10,6 +28,13 @@ export default defineConfig({
}
},
server: {
port: 5173
host: '0.0.0.0',
port: 5173,
proxy: createApiProxy()
},
preview: {
host: '0.0.0.0',
port: 4173,
proxy: createApiProxy()
}
})