跨域

parent c4afff33
Showing with 3 additions and 0 deletions
......@@ -65,6 +65,9 @@ func Output(ctx *gin.Context, errCode int, errMsg string, data interface{}) {
referer = strings.TrimRight(referer, "/")
ctx.Header("Access-Control-Allow-Origin", referer)
ctx.Header("Access-Control-Allow-Credentials", "true")
ctx.Header("Access-Control-Allow-Headers", "*")
ctx.Header("Access-Control-Allow-Methods", "GET,HEAD,POST,PUT,DELETE,OPTIONS")
ctx.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type")
//允许跨站访问的站点域名
//跨域请求头设置
ctx.JSON(200, response)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment