feat: rebuild support workspace frontend
This commit is contained in:
@@ -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()
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user