我在前端的请求是这样的:
//获取强档推荐数据
$.ajax({
url: '/ly/Recommend/get/',
data: {
adpos: 907,
num: 24,
pool_id: 302
},
success(data){
let obj = JSON.parse(data);
console.log(obj);
},
error(error){
console.log(error);
}
});
我在服务端用 http-proxy-middleware 做了代理:
let o = {
target: 'https://ac.qq.com/',
changeOrigin: true,
pathRewrite: {
'^/ly': ''
}
};
app.use('/ly', proxy(o));
用谷歌浏览器测试,pc 端请求成功,而移动端模式报错:
Failed to load https://m.ac.qq.com/Recommend/get/: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8088' is therefore not allowed access.
可以看到,请求地址代理到了 https://m.ac.qq.com/,但是我明明写的是 https://ac.qq.com/ ,请问这个问题该怎么解决?
相关问题
- Can't configure nginx as a proxy for tomcat wi
- R connect via proxy in Ubuntu
- Java - How to get annotations from Proxy class?
- What is the actual purpose of designing a proxy cl
- How to access the Internet through Proxy in C#
相关文章
- tp5.1.前后端分离.cros跨域问题.在线上找了各种方法.没辙了
- netcore3.1 WebApi独立运行跨域设置无效
- Angular CLI: Proxy websocket with proxy.conf.json
- OSX proxy issue with homebrew install
- What to do with extra HTTP header from proxy?
- Firebug console error HTTP 407 Proxy Authenticatio
- How to set a proxy in rubys net/http?
- Bypass the proxy using TcpClient
移动端请求 ac.qq.com 时服务端自动重定向到了 m.ac.qq.com ,需要在 CORS 设置中加上
https://m.ac.qq.com/