47 Star 687 Fork 250

wejectchan / Ginblog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
cors.go 603 Bytes
一键复制 编辑 原始数据 按行查看 历史
wejectchan 提交于 2023-10-31 14:11 . fix some bugs.
package middleware
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"time"
)
// Cors 跨域中间件
func Cors() gin.HandlerFunc {
return cors.New(
cors.Config{
//AllowAllOrigins: true,
AllowOrigins: []string{"*"}, // 等同于允许所有域名 #AllowAllOrigins: true
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowHeaders: []string{"*", "Authorization"},
ExposeHeaders: []string{"Content-Length", "text/plain", "Authorization", "Content-Type"},
AllowCredentials: true,
MaxAge: 12 * time.Hour,
},
)
}
Go
1
https://gitee.com/wejectchan/ginblog.git
git@gitee.com:wejectchan/ginblog.git
wejectchan
ginblog
Ginblog
master

搜索帮助