diff --git a/docker-compose.yml b/docker-compose.yml index 916a9e1..5362002 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ services: build: context: ./frontend args: - - VITE_API_URL=http://6.6.6.66:8000/api + - VITE_API_URL=/api # volumes: # - ./frontend:/app # - /app/node_modules diff --git a/frontend/Dockerfile b/frontend/Dockerfile index d6aa5bf..7e63e36 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -12,7 +12,7 @@ RUN npm install --registry=https://registry.npmmirror.com COPY . . # 接收构建参数 -ARG VITE_API_URL=http://localhost:8000/api +ARG VITE_API_URL=/api # 设置环境变量供构建时使用 ENV VITE_API_URL=$VITE_API_URL diff --git a/frontend/vite.config.js b/frontend/vite.config.js index b732916..42ef5d0 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -12,6 +12,24 @@ export default defineConfig({ preview: { host: '0.0.0.0', port: 15173, - allowedHosts: ['market.quant-speed.com'] + allowedHosts: ['market.quant-speed.com'], + proxy: { + '/api': { + target: 'http://backend:8000', + changeOrigin: true, + }, + '/admin': { + target: 'http://backend:8000', + changeOrigin: true, + }, + '/static': { + target: 'http://backend:8000', + changeOrigin: true, + }, + '/media': { + target: 'http://backend:8000', + changeOrigin: true, + } + } } })