http head

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With")

//允许共享
w.Header().Set("Access-Control-Allow-Credentials", "true")
//愿意共享给:http://localhost:9000
w.Header().Set("Access-Control-Allow-Origin", "http://localhost:9000")

Access-Control-Allow-Origin

https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Allow-Origin

Access-Control-Allow- 设置 跨域资源共享 CORS 详解

https://blog.csdn.net/weixin_42273457/article/details/84527410

原文地址:https://www.cnblogs.com/javalzy/p/13592056.html