nginx解决跨域问题
1.宝塔面板,在网站内设置伪静态
location /test{ proxy_pass https://baidu.com; }
2.前端请求写法
$.ajax({ type: 'POST', url: '/test/index/getOrder', //请求地址只需简写,当nginx检测到test时,会自动替换为https://baidu.com/test/index/getOrder data: params, success: function (ret) { console.log(ret) } });