项目打包-nginx-基本使用
执行打包命令
npm run build:prod
得到dist文件包
windows-安装-nginx
https://nginx.org/en/download.html
windows环境下nginx部署启动项目
1. 将打包的文件放置到安装目录/html下
把打包之后的文件,放在html目录下:
2. windows版本启动服务
双击图标
nginx解决history的404问题
修改配置文件
windows下的配置文件
location / {
try_files $uri $uri/ /index.html;
}
nginx配置代理解决生产环境跨域问题
修改配置文件
location /prod-api {
# proxy_pass https://heimahr-t.itheima.net;
proxy_pass https://heimahr.itheima.net/api;
}
``
**注意:**
**千万要注意任务管理器中只能打开一个nginx进程,不然最新的配置无法生效.**