Files
wechat_ipad_pro/api/middleware/cors.go
2026-02-17 13:06:23 +08:00

17 lines
442 B
Go

package middleware
import (
"github.com/gin-gonic/gin"
)
func Cors(c *gin.Context) {
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
if c.Request.Method == "OPTIONS" {
c.AbortWithStatus(204)
return
}
c.Next()
}