Skip to content

Commit

Permalink
add Access-Control-Max-Age by OPTIONS (#9257)
Browse files Browse the repository at this point in the history
Update serve.go

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

对于 OceanPress 这类工具而言,能够获得更快的速度
  • Loading branch information
2234839 authored Sep 25, 2023
1 parent bb59ed9 commit 3c2f4e5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions kernel/server/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 3c2f4e5

Please sign in to comment.