Categorygithub.com/AlexZ33/goweb-cors
repositorypackage
0.0.0-20221221095704-bc7657213bbb
Repository: https://github.com/alexz33/goweb-cors.git
Documentation: pkg.go.dev

# README

goweb-cors

Cross-origin_resource_sharing util for golang

What is CORS ?

CORS请求保护不当可导致敏感信息泄漏,因此应当严格设置Access-Control-Allow-Origin使用同源策略进行保护。

c := cors.New(cors.Options{
	AllowedOrigins:   []string{"http://qq.com", "https://qq.com"},
	AllowCredentials: true,
	Debug:            false,
})

// 引入中间件
handler = c.Handler(handler)