假如跨域请求的接口为:http://xxx.cn/was5/web/search
Nginx配置:
在conf/nginx.conf文件中
location / {
root html;
index index.html index.htm;
}
后面增加
location /was5{ proxy_pass http://xxx.cn; }
配置之后,将js请求接口改为:/was5/web/search
重启Nginx服务,浏览器访问http://localhost即可,默认端口80,可在conf/nginx.conf更改端口