欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

vue-cli项目打包后代理接口报404错误解决办法

程序员文章站 2022-08-20 12:59:14
vue-cli 项目打包后 代理接口报404错误 解决办法! 1、启动nginx cd usr/local/nginx/sbin ./nginx 2、找到nginx安装目录 whereis ngin...

vue-cli 项目打包后 代理接口报404错误 解决办法!

1、启动nginx

cd usr/local/nginx/sbin

./nginx

2、找到nginx安装目录

whereis nginx

cdusr/local/nginx/

3、打开nginx 配置文件

cd conf/

vi nginx.conf 按i 修改,新增配置

location /api {
                proxy_set_header   host             $host;
                proxy_set_header   x-forwarded-for  $remote_addr;
                proxy_set_header   x-real-ip        $remote_addr;
                proxy_pass https://xxx.xx.xx.xxx:xxxx; // 接口地址
        }