一、背景描述:
react打包出来的文件,想部署在 如 https://www.abc.com/webapp下,
本项目使用的是history:hash 模式,
如果使用的是history:browser ,可参考该大神的文章https://www.freesion.com/article/5887723973/
二、解决方法
1、修改/添加 配置
// package.json
"homepage":"."
2、在每一个index.html文件添加
# webapp 是你自己文件夹的名称
<base href="/webapp/">
3、将打包后的文件丢到服务器
4、nginx添加配置,重启
location /webapp/ {
index index.html index.htm;
}