Sfoglia il codice sorgente

feat: configure session store options for API routes

- Set session cookie path to "/api"
- Disable secure flag for local development
- Enable HttpOnly flag for improved security
1808837298@qq.com 1 anno fa
parent
commit
6acc37cf27
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  1. 5 0
      main.go

+ 5 - 0
main.go

@@ -145,6 +145,11 @@ func main() {
 	middleware.SetUpLogger(server)
 	// Initialize session store
 	store := cookie.NewStore([]byte(common.SessionSecret))
+	store.Options(sessions.Options{
+		Path:     "/api",
+		Secure:   false,
+		HttpOnly: true,
+	})
 	server.Use(sessions.Sessions("session", store))
 
 	router.SetRouter(server, buildFS, indexPage)