Merge 5f4ebeba9573a1dc7f089cc8325a4a022976a212 into d7eb05b9361febead29a74e71ddffc2ebeff5302

This commit is contained in:
Justin Cranford 2024-11-14 13:54:54 +08:00 committed by GitHub
commit b9eb55921e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1128,6 +1128,13 @@ func allowedHostsMiddleware(addr net.Addr) gin.HandlerFunc {
}
}
func CacheControlMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
c.Header("Cache-Control", "max-age=0")
c.Next()
}
}
func (s *Server) GenerateRoutes() http.Handler {
config := cors.DefaultConfig()
config.AllowWildcard = true
@ -1141,6 +1148,7 @@ func (s *Server) GenerateRoutes() http.Handler {
r := gin.Default()
r.Use(
CacheControlMiddleware(),
cors.New(config),
allowedHostsMiddleware(s.addr),
)