脚本宝典收集整理的这篇文章主要介绍了记react 代理后使用nginx发布到阿里云服务器,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
近期在搭建自己的简单博客系统,在本地可以前后台分离的运行,但是部署到服务器就总是会404,最后在react官网问答上面找到了答案。
1.react设置了项目代理
package.json
...//其他部分省略
"Proxy": "http://www.iamcrawler.cn"
2 npm run build
3.服务器nginx配置:
server {
listen 80 ;
server_name localhost:4000;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /react/build;
index index.htm index.htML;
}
location /api/ {
PRoxy_pass http://127.0.0.1:4000;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
1.第一个localtion /: 前台地址
2.第二个location /api/ 后台带/api的请求地址
附上原问答地址:http://react-china.org/t/reac...
以上是脚本宝典为你收集整理的记react 代理后使用nginx发布到阿里云服务器全部内容,希望文章能够帮你解决记react 代理后使用nginx发布到阿里云服务器所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。