通过nginx proxy manager解决https站点访问http接口资源报错问题

发布时间 2023-04-15 18:19:11作者: 南柯Dream丶

浏览器控制台报

Mixed Content: The page at '<URL>' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint '<URL>'. This request has been blocked; the content must be served over HTTPS.

这说明 你的网站部署上服务器已经启用了ssl证书 默认web站点为https协议
当你站点去请求http协议时就会报以上错误
此时我们可以通过nginx proxy manager反向代理接口

  1. 先去cloudflare新填一条DNS二级域名
  2. 打开终端ping下http接口域名得到ip
  3. 到n p manger添加一条反向代理记录并开启ssl
  4. 最后到postman测试(原接口域名修改为你自己代理的域名,后面接口资源路径照抄即可)
  5. 最后,如果接口测试通过,我们就可以到vue项目中将axios生产环境请求路径修改为上面请求url即可
  6. 重新打包项目上传服务器