diff --git a/main.go b/main.go index b648231..ca0d0d3 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( func main() { r := gin.Default() + r.Use(Cors()) r.POST("/sql", func(c *gin.Context) { var req struct { Content string `json:"content"` @@ -32,15 +33,14 @@ func main() { c.String(http.StatusOK, string(res)) }) r.StaticFS("/", http.FS(web.Static)) - r.Use(Cors()) r.Run(":8000") } func Cors() gin.HandlerFunc { return cors.New(cors.Config{ - AllowOrigins: []string{"*"}, - AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "PATCH"}, + AllowAllOrigins: true, AllowCredentials: true, + AllowHeaders: []string{"*"}, MaxAge: time.Second * time.Duration(7200), }) }