add Access-Control-Max-Age by OPTIONS (#9257)

Update serve.go

避免每次请求都发送预检请求。

对于 OceanPress 这类工具而言,能够获得更快的速度
This commit is contained in:
崮生
2023-09-25 08:41:50 +08:00
committed by GitHub
parent bb59ed97e5
commit 3c2f4e50e1

View File

@@ -530,6 +530,7 @@ func corsMiddleware() gin.HandlerFunc {
c.Header("Access-Control-Allow-Private-Network", "true")
if c.Request.Method == "OPTIONS" {
c.Header("Access-Control-Max-Age", 600)
c.AbortWithStatus(204)
return
}