Hello,World.

秋风与你,偏安一隅.

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)
  }
  });

 

posted @ 2021-03-09 14:05  秋风荡  阅读(224)  评论(0编辑  收藏  举报