Web跨域

1.【必须】跨域资源共享CORS限制请求来源

  • CORS请求保护不当可导致敏感信息泄漏,因此应当严格设置Access-Control-Allow-Origin使用同源策略进行保护。
 // good
  c := cors.New(cors.Options{
      AllowedOrigins: []string{"http://qq.com", "https://qq.com"},
      AllowCredentials: true,
      Debug: false,
  })

  //引入中间件
  handler = c.Handler(handler)
最后编辑: kuteng  文档更新时间: 2021-06-04 17:24   作者:kuteng