yarn build
将打包生成的dist文件夹复制到nginx目中的html文件夹中
conf 目录下的 nginx.conf 文件
server {
listen 3100;
server_name 127.0.0.1;
location / {
root D:/soft/nginx-1.18.0/html/dist; # 指定vue项目打包的绝对路径
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# 调接口请求,反向代理,实现跨域
location ^~ /api/ {
proxy_pass http://127.0.0.1:8080/;
}
}
cmd窗口 或者 管理员身份的powerShell 执行 nginx -s reload
原文:https://www.cnblogs.com/yezi-zq/p/14731236.html