feat: 更新CORS配置支持更多HTTP方法

This commit is contained in:
2026-01-07 00:23:02 +08:00
parent 8240d8cf94
commit cf751c4c28
2 changed files with 3 additions and 5 deletions

View File

@@ -1,3 +1 @@
[
]
[]

View File

@@ -113,11 +113,11 @@ func main() {
// 添加CORS中间件
r.Use(func(c *gin.Context) {
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
c.Writer.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
c.Writer.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization")
if c.Request.Method == "OPTIONS" {
c.AbortWithStatus(204)
c.AbortWithStatus(200)
return
}