当前位置: 首页 > 面试题库 >

如何将create-react-app部署到Google Cloud

文英达
2023-03-14
问题内容

我有一个使用Expressjs的前端create-react-app和一个后端API。

我已将后端API成功部署到Google App Engine。

但是现在我需要将create-react-app部署到Google Cloud,这变得
非常令人困惑,我尝试了一段时间的google,目前尚无真正/推荐的
方法。

至少我看到其他人建议以两种方式这样做:

1.使用Google云端存储:

    * 运行“ npm run build”来创建“ build”文件夹

 * 将此整个文件夹上传到存储桶中

=>我看到使用这种方式有一个缺点:当我尝试重新加载
页面’url / aboutUs’时,找不到它。因此,我必须返回“ URL”,然后单击
“关于我们”链接

=>我猜我正在使用的React Router无法与Google
Cloud Storage一起使用

使用Google App Engine
=>人们只是在谈论使用它,但是我找不到有关它的任何指南/教程

那么,将create-react-app部署到Google Cloud的推荐方法是什么?

您能提供一个教程吗?

谢谢。


问题答案:

你只需要配置云端存储分区,以服务index.html为404页。

对于Google App Engine,您可以使用serve或设置nginx 在build 文件夹中进行投放index.html。



 类似资料:
  • 问题内容: 我正在尝试在Google App Engine上部署使用create-react-app创建的应用程序。 我的应用程序在本地(和)都可以正常运行。但是,在Google App Engine上部署的应用程序仅显示index.html,并且不会调用我的react代码。 Chrome开发者控制台显示。 另外,我在console.cloud.google.com上发现,已部署的应用程序不包含构

  • 问题内容: 如何在Apache WAMP / XAMPP服务器上部署构建? 我创建了一个应用,并且在此应用上有两个页面 当我执行或运行正常并且所有页面在URL导航或按钮单击上均正确呈现时 我执行了构建命令 npm运行构建 它会在文件夹中生成所有和文件。 我搬到这个build文件夹中的内容的文件夹,并执行对URL 的只显示主页。然后下一页给出 但是当我执行npm命令的模块时,它在 服务构建 请帮我如

  • Create React App 不用配置就可以创建 React App。 全局安装: npm install -g create-react-app 创建 App: create-react-app my-appcd my-app/ 启动 npm: npm start 打开 http://localhost:3000/  查看你的 App。 如果你准备将其部署到生产环境,只需创建一个压缩包,并且运行 npm run build。

  • Create React Native App The fastest way to create universal React Native apps npx create-react-native-app Once you're up and running with Create React Native App, visit this tutorial for more informat

  • Create React Redux App Structure Create React + Redux app structure with build configurations. What can I find here? Express, Cors React + Redux, ES6, async/await Web Components (Custom Elements) inte

  • create-react-app React Project with Node Express Backend Example on using create-react-app with a Node Express Backend Usage Install nodemon globally npm i nodemon -g Install server and client depende