假如跨域請求的接口為: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更改端口
