feat: rename CORS_ALLOW_ORIGIN to ASTRBOT_CORS_ALLOW_ORIGIN and add it to .env.example

This commit is contained in:
LIghtJUNction
2026-04-03 01:01:31 +08:00
parent 7b11f90d7b
commit 252c62379e
2 changed files with 8 additions and 2 deletions

View File

@@ -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
# ------------------------------------------

View File

@@ -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 = [