fix cookies not match while using subPath (#51)

This commit is contained in:
Sharl.Jimh.Tsin 2023-04-11 13:50:20 +08:00 committed by GitHub
parent 8e31fe25ac
commit 2ea9df0aba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,11 +23,12 @@ type StatsData struct {
var (
key = []byte(securecookie.GenerateRandomKey(32))
store = sessions.NewCookieStore(key)
conf = config.LoadedConfig()
)
func init() {
store.Options = &sessions.Options{
Path: "/stats",
Path: conf.BaseURL+"/stats",
MaxAge: 3600 * 1, // 1 hour
HttpOnly: true,
SameSite: http.SameSiteStrictMode,
@ -43,8 +44,6 @@ func Stats(w http.ResponseWriter, r *http.Request) {
return
}
conf := config.LoadedConfig()
if conf.DatabaseType == "none" {
render.PlainText(w, r, "Statistics are disabled")
return