1

I am using Google Cloud Platform's PHP based static server. My public folder contains one landing page and and a web-app.

The landing page just is a static html file with few css and image files which resides on root.

The web-app is made of React, it's index.html resides inside the folder named app

I have configured my react app to use BrowserRouter.

The web-app returns 404 error when I refresh any page inside the app.

How to configure app.yaml to solve this. My current configuration is below:

    runtime: php55
    api_version: 1
    threadsafe: true
    skip_files: 
    - src/
    - node_modules/
    - ^(.*/)?app\.yaml
    - ^(.*/)?gitlab\.yml
    - ^(.*/)?app\.yaml
    - ^package\.json
    - ^package-lock\.json
    - ^README\.md
    - ^webpack.config\.js
    - ^(.*/)?#.*#
    - ^(.*/)?.*~
    - ^(.*/)?.*\.py[co]
    - ^(.*/)?.*/RCS/.*
    - ^(.*/)?\..*

    handlers:
    - url: /
      static_files: public/index.html
      upload: public/index.html
      secure: always

    - url: /app/(.*\.(html|js|css))$
      static_files: public/app/\1
      upload: public/app/.*\.(html|js|css)$
      secure: always

    - url: /(.*)
      static_files: public/\1
      upload: public/(.*)
      secure: always

I want to achieve something like nginx server's try_files option.

Sivadass N
  • 803
  • 3
  • 12
  • 22

0 Answers0