From cffdea5407206311f7538bda62891a9ee6ef854a Mon Sep 17 00:00:00 2001 From: Sakurasan <26715255+Sakurasan@users.noreply.github.com> Date: Mon, 6 Jul 2026 02:30:38 +0800 Subject: [PATCH] up --- docker-compose.yml | 7 +++---- src/lib/api-client.ts | 13 ++++++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e854e1a..15655da 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,9 @@ services: app: - image: ${DOCKER_USER:-mirrors2}/meoo:${VERSION:-latest} - build: - context: . + image: ${DOCKER_USER:-mirrors2}/auv:${VERSION:-latest} + container_name: auv ports: - "8000:8000" env_file: - - ./backend/.env + - .env restart: unless-stopped diff --git a/src/lib/api-client.ts b/src/lib/api-client.ts index 92ea847..b618731 100644 --- a/src/lib/api-client.ts +++ b/src/lib/api-client.ts @@ -1,6 +1,13 @@ -// Python 后端 API 客户端 — 自动适配局域网 IP -// 前端 JS 在浏览器中运行时,API 用当前页面的 hostname(端口 8000) -const API_BASE = `http://${window.location.hostname}:8000`; +// Python 后端 API 客户端 +// 生产环境:同源反代,用相对路径 +// 开发环境:Vite 3015 → 后端 8000,显式跨域 +const API_BASE = (() => { + const { hostname, port } = window.location; + if (port === '3015') { + return `http://${hostname}:8000`; + } + return ''; +})(); export function getApiBaseUrl(): string { return API_BASE;