Search code examples
reactjsgoogle-cloud-platformgatsby

Managing handlers when storing React+Gatsby static App on GCP


My React App is already running on GCP engine. Navigation and all the pages look fine but direct links are causing issues - for example, if I open myWebsite.com/vacancies, I'll get the error log saying that Static file referenced by handler not found: public/vacancies//index.html. Here's my app.yaml handlers config:

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

  - url: /((.*\/)*[^\/]+\.[^\/]+)$
    static_files: public/\1
    upload: public/.*

  - url: /(.*)$
    static_files: public/\1/index.html
    upload: public/.*/index.html

The workaround is opening the page like this myWebsite.com/vacancies/index.html, but I'd like to find more smooth solution. Thanks in advance


Solution

  • The solution for my case:

      - url: /(.*)\/$
        static_files: public/\1/index.html
        upload: public/.*index.html
    
      - url: /(.*)$
        static_files: public/\1/index.html
        upload: public/.*/index.html