typeofgraphic
typeofgraphic

Reputation: 322

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

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

Upvotes: 3

Views: 2943

Answers (1)

GAEfan
GAEfan

Reputation: 11370

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.

Upvotes: 8

Related Questions