将create-react-app构建部署到Google Cloud Platform后找不到URL [英] URLs not found after deploying create-react-app build to Google Cloud Platform

本文介绍了将create-react-app构建部署到Google Cloud Platform后找不到URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将一个create-react-app版本(带有app.yaml文件)上传到GCP存储桶。然后,该应用已使用云外壳部署到App Engine实例上。

I've uploaded a create-react-app build (with an app.yaml file) to a GCP bucket. The app has then been deployed on a App Engine instance using the cloud shell.

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

Going to the app's root URL works fine. But going to example.com/anything returns the following error:


错误:未找到

Error: Not Found

在此服务器上找不到请求的URL /任何内容。

The requested URL /anything was not found on this server.

App.yaml文件如下:

App.yaml file looks like this:

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


推荐答案

您没有用于 /任何内容的处理程序。如果要使用全部网址,请使用正则表达式类型处理程序:

You don't have a handler for /anything. If you want a catch-all url, use regex type handler:

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

或者,如果需要将它们作为静态文件提供给 anything.html ,将其放入您的 build 目录中,然后导航至 /anything.html 。您的第一个处理程序已设置为映射该网址。

or, if you want to serve them anything.html as a static file, put it in your build dir, and navigate to /anything.html. Your first handler is set up to map that url.

这篇关于将create-react-app构建部署到Google Cloud Platform后找不到URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆