feat: 增强 Cookie 设置日志,提供 HTTPS 配置建议

pull/1451/head
墨梓柒 2025-12-16 13:19:47 +08:00
parent a5880522e7
commit 48f2d1c33c
No known key found for this signature in database
GPG Key ID: 4A65B9DBA35F7635
1 changed files with 6 additions and 1 deletions

View File

@ -108,7 +108,12 @@ def set_auth_cookie(response: Response, token: str, request: Optional[Request] =
# 如果是 HTTP 连接,强制禁用 secure 标志
if not is_https and is_secure:
logger.warning("检测到 HTTP 连接但配置要求 secure cookie强制禁用 secure 以允许 cookie 工作")
logger.warning("=" * 80)
logger.warning("检测到 HTTP 连接但环境配置要求 HTTPS (secure cookie)")
logger.warning("已自动禁用 secure 标志以允许登录,但建议修改配置:")
logger.warning("1. 在 .env 文件中设置: WEBUI_SECURE_COOKIE=false")
logger.warning("2. 如果使用反向代理,请确保正确配置 X-Forwarded-Proto 头")
logger.warning("=" * 80)
is_secure = False
# 设置 Cookie