如何将 create-react-app 部署到 Google 云
How to deploy create-react-app to Google Cloud
我有一个前端 create-react-app 和一个使用 Expressjs 的后端 API。
我已成功将后端 API 部署到 Google App Engine。
但是现在我需要将 create-react-app 部署到 Google Cloud 并且它变得非常混乱,我尝试了一段时间 google 并且没有 true/recommended方法。
至少我看到其他人建议用两种方式来做:
使用Google云存储:
运行 "npm run build" 创建 "build" 文件夹
将整个文件夹上传到存储桶
=> 我发现使用这种方式有一个缺点:当我尝试重新加载页面 'url/aboutUs' 时,找不到它。所以我必须返回 'url' 然后点击关于我们 link
=> 我猜想我正在使用的 React Router 无法与 Google Cloud Storage
一起使用
- 使用 Google App Engine
=> 人们刚刚谈到使用它,但我找不到任何 guide/tutorial 的。
那么将 create-react-app 部署到 Google 云的推荐方法是什么?
你能提供一个教程吗?
谢谢。
您只需将 Cloud Storage 存储桶配置为 serve index.html
as the 404 page。
对于 Google App Engine,您可以使用 serve or set up nginx to serve index.html
in the build folder。
我有一个前端 create-react-app 和一个使用 Expressjs 的后端 API。
我已成功将后端 API 部署到 Google App Engine。
但是现在我需要将 create-react-app 部署到 Google Cloud 并且它变得非常混乱,我尝试了一段时间 google 并且没有 true/recommended方法。
至少我看到其他人建议用两种方式来做:
使用Google云存储:
运行 "npm run build" 创建 "build" 文件夹
将整个文件夹上传到存储桶
=> 我发现使用这种方式有一个缺点:当我尝试重新加载页面 'url/aboutUs' 时,找不到它。所以我必须返回 'url' 然后点击关于我们 link
=> 我猜想我正在使用的 React Router 无法与 Google Cloud Storage
一起使用- 使用 Google App Engine
=> 人们刚刚谈到使用它,但我找不到任何 guide/tutorial 的。
那么将 create-react-app 部署到 Google 云的推荐方法是什么?
你能提供一个教程吗?
谢谢。
您只需将 Cloud Storage 存储桶配置为 serve index.html
as the 404 page。
对于 Google App Engine,您可以使用 serve or set up nginx to serve index.html
in the build folder。