URLs not found after deploying create-react-app build to Google Cloud Platform

女生的网名这么多〃 提交于 2020-06-26 21:18:24

问题


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.

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

Error: Not Found

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

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

回答1:


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

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.



来源:https://stackoverflow.com/questions/48015085/urls-not-found-after-deploying-create-react-app-build-to-google-cloud-platform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!