解决本地http系统访问https接口跨域问题:
背景:前端系统使用nginx代理,前端访问地址为http://127.0.0.1/xxx,要访问第三方https://xxx.cn 解决步骤:
1、在nginx代理的server中配置代理,如下图:
server {
listen 80;
server_name 127.0.0.1;
# 本地项目配置
location /XXX {
alias F:/XXXX/XXX;
index index.html index.htm;
}
# 第三方接口代理配置
location /api{
proxy_pass https://xxx.cn/;
}
}
复制代码
2、在项目中第三方访问接口的地址配置地址如下:
/api/xxx
XXX为代理地址的接口与参数部分
复制代码
以上两步即可解决http访问https跨域问题。