diff --git a/.env.example b/.env.example index c28f34b04..a9ae5f28a 100644 --- a/.env.example +++ b/.env.example @@ -80,6 +80,12 @@ ASTRBOT_SYSTEMD=1 # 默认 Default: True ASTRBOT_DASHBOARD_ENABLE=True +# 允许跨域请求的来源域名(多个用逗号分隔,允许所有则用 *) +# Allowed CORS origins for WebUI dashboard (comma-separated, or * for all) +# 示例 Example: https://dash.astrbot.men +# 默认 Default: * +# ASTRBOT_CORS_ALLOW_ORIGIN="*" + # ------------------------------------------ # 国际化配置 / Internationalization Configuration # ------------------------------------------ diff --git a/astrbot/dashboard/server.py b/astrbot/dashboard/server.py index e8f1132d9..6fc2751ee 100644 --- a/astrbot/dashboard/server.py +++ b/astrbot/dashboard/server.py @@ -236,9 +236,9 @@ class AstrBotDashboard: self.app.json.sort_keys = False # 配置 CORS - # 支持通过环境变量 CORS_ALLOW_ORIGIN 配置允许的域名,多个域名用逗号分隔 + # 支持通过环境变量 ASTRBOT_CORS_ALLOW_ORIGIN 配置允许的域名,多个域名用逗号分隔 # 如果前端使用 withCredentials:true,需要设置具体的域名而非 "*" - cors_allow_origin = os.environ.get("CORS_ALLOW_ORIGIN", "*") + cors_allow_origin = os.environ.get("ASTRBOT_CORS_ALLOW_ORIGIN", "*") cors_allow_credentials = False if cors_allow_origin != "*": cors_allow_origin = [