fix: session cookie options for HTTP (insecure override + auto secure)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-05-12 16:02:50 +08:00
parent 9632b91e70
commit 03a5a43f30
2 changed files with 41 additions and 5 deletions
+6 -2
View File
@@ -26,7 +26,11 @@
# 在 Nginx/Caddy 等反向代理后部署时:信任 X-Forwarded-*,以便 Cookie、CSRF 与 HTTPS 判断正确
# NAV_TRUST_PROXY=1
# 站点仅通过 https:// 对外访问时建议开启;若用 http://内网IP:端口 访问请勿开启,否则浏览器不保存登录 Cookie
# NAV_SESSION_COOKIE_SECURE=1
# 会话 Cookie 的 Secure 标志(与浏览器地址栏是否 https 一致才有效):
# - 内网用 http://IP:端口:不要写 NAV_SESSION_COOKIE_SECURE=1;或保留 1 时另加 NAV_COOKIES_INSECURE_HTTP=1 强制关闭 Secure
# - 纯 https 对外:NAV_SESSION_COOKIE_SECURE=1
# - 反代后同时有 http/https:可试 NAV_SESSION_COOKIE_SECURE=auto(并配合 NAV_TRUST_PROXY=1
# NAV_COOKIES_INSECURE_HTTP=1
# NAV_SESSION_COOKIE_SECURE=auto
# CSRF 校验仍失败时,可填前端访问的完整 Origin,多个用英文逗号分隔,例如:
# NAV_CSRF_TRUSTED_ORIGINS=https://nav.example.com