如何将create-react-app部署到Google Cloud [英] How to deploy create-react-app to Google Cloud
问题描述
我有一个使用Expressjs的前端create-react-app和一个后端API。
$ b 我成功地将后端API部署到Google App Engine。 b
$ b
但现在我需要将create-react-app部署到Google Cloud,它变得非常混乱,我尝试了谷歌一段时间,并且没有真正/推荐的方式。 / p>
至少我看到其他人建议以两种方式来做:
-
使用Google云端存储:
-
运行npm run build创建build文件夹
-
将整个文件夹上传到存储桶中
b -
- 使用Google App Engine
Using Google Cloud Storage:
Run "npm run build" to create the "build" folder
Upload this whole folder onto a bucket
- Using Google App Engine
$ b
=>我发现使用这种方法有一个缺点:当我尝试重新加载页面'url / aboutUs'时,找不到它。所以我必须回到'url',然后点击关于我们的链接
=>我想我正在使用的React路由器不能与Google Cloud存储
=>人们只是谈论使用它,但我找不到任何指南/教程。
所以推荐的部署方式是什么?创建反应 - 谷歌云应用程序?您可以请提供一个教程吗?
谢谢。
您只需将Cloud Storage存储桶配置为
对于Google App Engine,您可以使用服务或设置 nginx 到 serve index.html
生成文件夹。
I have a frontend create-react-app and a backend API using Expressjs.
I deployed the backend API to Google App Engine successfully.
But now I need to deploy the create-react-app to Google Cloud and it becomes very confusing, I tried to google for a while and there is no true/recommended way for this.
At least I saw that other people suggested doing it in 2 ways:
=> I see that there is one drawback using this way: When I tried to reload page 'url/aboutUs', it's not found. So I have to go back to 'url' then click the About Us link
=> I guess that the React Router that I'm using is not working with Google Cloud Storage
=> People just talked about using it, but I can't find any guide/tutorial for this.
So what is the recommended way to deploy create-react-app to Google Cloud?
And can you please provide a tutorial for that?
Thanks.
You just need to configure the Cloud Storage bucket to serve index.html
as the 404 page.
For Google App Engine, you can use serve or set up nginx to serve index.html
in the build folder.
这篇关于如何将create-react-app部署到Google Cloud的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!