chore: sync with gin-template

This commit is contained in:
JustSong
2022-11-22 11:04:06 +08:00
parent 8247192977
commit 5913266969
41 changed files with 813 additions and 490 deletions
+2 -10
View File
@@ -1,20 +1,12 @@
package middleware
import (
"github.com/gin-gonic/contrib/cors"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"time"
)
func CORS() gin.HandlerFunc {
config := cors.DefaultConfig()
config.AllowedHeaders = []string{"Authorization", "Content-Type", "Origin",
"Connection", "Accept-Encoding", "Accept-Language", "Host"}
config.AllowedMethods = []string{"GET", "POST", "DELETE", "OPTIONS", "PUT"}
config.AllowCredentials = true
config.MaxAge = 12 * time.Hour
// if you want to allow all origins, comment the following two lines
config.AllowAllOrigins = false
config.AllowedOrigins = []string{"https://message-pusher.vercel.app"}
config.AllowOrigins = []string{"https://gin-template.vercel.app", "http://localhost:3000/"}
return cors.New(config)
}