【问题标题】:URLs not found after deploying create-react-app build to Google Cloud Platform将 create-react-app build 部署到 Google Cloud Platform 后找不到 URL
【发布时间】:2018-06-09 10:49:01
【问题描述】:

我已将 create-react-app 构建(带有 app.yaml 文件)上传到 GCP 存储桶。然后,该应用已使用 Cloud Shell 部署在 App Engine 实例上。

转到应用的根 URL 可以正常工作。但是转到example.com/anything 会返回以下错误:

错误:未找到

在此服务器上找不到请求的 URL /anything。

App.yaml 文件如下所示:

runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /(.*\.(html|css|js))
  static_files: build/\1
  upload: build/(.*\.(html|css|js))

- url: /
  static_files: build/index.html
  upload: build/index.html

【问题讨论】:

  • 使用url: .* 作为第二个处理程序。
  • 嗨@typeofgraphic,你能分享一下如何逐步将create-react-app部署到Google App Engine吗?谢谢

标签: reactjs google-app-engine google-cloud-platform google-cloud-storage create-react-app


【解决方案1】:

您没有/anything 的处理程序。如果你想要一个包罗万象的 url,请使用正则表达式类型处理程序:

- url: /.*
  static_files: build/index.html
  upload: build/index.html

或者,如果您想将anything.html 作为静态文件提供服务,请将其放在您的build 目录中,然后导航到/anything.html。您的第一个处理程序已设置为映射该 url。

【讨论】:

    猜你喜欢
    • 2018-10-19
    • 2019-06-05
    • 2023-04-07
    • 2017-09-21
    • 1970-01-01
    • 1970-01-01
    • 2018-07-16
    • 2018-09-06
    • 1970-01-01
    相关资源
    最近更新 更多