


在做一个公众号商城,遇到了跨域问题。
后端用了beego框架
ctx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS") ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*") ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "Content-Type,Authorization") ctx.ResponseWriter.Header().Set("Access-Control-Max-Age", "1728000") ctx.ResponseWriter.Header().Set("Access-Control-Allow-Credentials", "true") ctx.ResponseWriter.Header().Set("content-type", "application/json")
mainfest设置
"h5":{ "devServer": { "port": 9000, "disableHostCheck": true, "proxy" : { "/" : { "target" : "http://localhost:6601/", //端口修改成你自己的 "changeOrigin" : true, "secure" : false, "pathRewrite" : { "^/" : "/" } } }, "https" : false } },
用了fly请求,所以拦截中千万不要设置baseURL!!不要设置baseURL!!不要设置baseURL!!
内容来源于网络如有侵权请私信删除
文章来源: 博客园
标签:
HTML
HTML5
你还没有登录,请先登录或注册!
- 还没有人评论,欢迎说说您的想法!
相关课程

3651
0元
限免

2798
0元
限免

4646
9.8元