nginx部署vue的问题

问题遇到的现象和发生背景

开发环境中配置的跨域在将项目打包为静态文件时是没有用的 。

问题相关代码,请勿粘贴截图
运行结果及报错内容
我的解答思路和尝试过的方法

需要用 nginx 通过反向代理的方式解决这个问题

我想要达到的结果

nginx部署vue的步骤

#vue打包baseUrl改成斜杠
#nginx配置
server {
#监听端口
listen 8880;
server_name localhost;
location / {
#vue打包后的路径
root d:/static/dist;
index index.html;
}
#请求
location /test/{
#后台地址
proxy_pass http://127.0.0.1:8081/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $http_x_real_ip;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}