feat: 准备 Admin 线上 HTTPS 部署 (#81)

This commit is contained in:
chengma
2026-08-10 02:46:59 +08:00
parent 78c0c4a73b
commit 8cc8574e8a
6 changed files with 101 additions and 9 deletions
+2 -2
View File
@@ -202,7 +202,7 @@ func safeNext(raw string) string {
func setAuthCookie(c *gin.Context, token string, expiresAt time.Time) {
http.SetCookie(c.Writer, &http.Cookie{
Name: authCookieName, Value: token, Path: "/", HttpOnly: true,
Secure: c.Request.TLS != nil, SameSite: http.SameSiteLaxMode,
Secure: requestIsHTTPS(c.Request), SameSite: http.SameSiteLaxMode,
Expires: expiresAt, MaxAge: int(service.WebSessionDuration.Seconds()),
})
}
@@ -210,7 +210,7 @@ func setAuthCookie(c *gin.Context, token string, expiresAt time.Time) {
func clearAuthCookie(c *gin.Context) {
http.SetCookie(c.Writer, &http.Cookie{
Name: authCookieName, Value: "", Path: "/", HttpOnly: true,
Secure: c.Request.TLS != nil, SameSite: http.SameSiteLaxMode,
Secure: requestIsHTTPS(c.Request), SameSite: http.SameSiteLaxMode,
Expires: time.Unix(1, 0), MaxAge: -1,
})
}