From 96bac1a7c15359fa7958db1eea4c51e3b42a5323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=80=E6=A2=A6?= <3501646051@qq.com> Date: Thu, 2 Apr 2026 12:15:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20CORS=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=9A=E5=8A=A0=E5=85=A5=E5=89=8D=E7=AB=AF=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=209948?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 前端 Vite 运行在 localhost:9948,但默认 CORS 只允许 8080/5173, 导致浏览器预检请求失败,前端报 Network Error --- .env.example | 2 +- core/config.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 93fe4c9..80721c4 100644 --- a/.env.example +++ b/.env.example @@ -35,4 +35,4 @@ PLUGINS_DIR=plugins # ==================== CORS配置 ==================== # 允许的来源域名,用逗号分隔 -CORS_ORIGINS=http://localhost:8080,http://localhost:5173 +CORS_ORIGINS=http://localhost:8080,http://localhost:5173,http://localhost:9948 diff --git a/core/config.py b/core/config.py index 855f4fa..7d67ba7 100644 --- a/core/config.py +++ b/core/config.py @@ -44,7 +44,7 @@ class Settings(BaseSettings): plugins_dir: str = "plugins" # CORS 配置 - cors_origins: str = "http://localhost:8080,http://localhost:5173" + cors_origins: str = "http://localhost:8080,http://localhost:5173,http://localhost:9948" @property def cors_origins_list(self) -> List[str]: