Error with refresh on frontend only react app

34 Views Asked by At

I'm trying to deploy a simple frontend only react website with google cloud console. Everything works fine except one thing.

When I refresh any page other than the index I have an Error Not Found /whatever was not found on this server

I understand it's because of how React works and the server cannot know all the inside link inside my react app.

How can i setup my app.yaml to redirect to index if the user refresh anypage ??

Here is my app.yaml

runtime: nodejs14

instance_class: F1
handlers:

#/ Serve all static files with url ending with a file extension
- url: /(.*\..+)$

  static_files: build/\1

  upload: build/(.*\..+)$

#/ Catch all handler to index.html
-url: /.*

  static_files: build/index.html

  secure: always

  redirect_http_response_code: 301

  script: auto
0

There are 0 best solutions below