How do I setup routing for react in GAE? Directly routing to react-router-dom routes via URL fails in GAE on basic create-react-app?

后端 未结 4 2021
星月不相逢
星月不相逢 2020-12-05 19:03

ANSWER for now

This was tough for me to get exactly right. Very little in the way of guidance via Google. I hope this helps others.

As D

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 19:41

    I took the answers from Nathan Shephard and Dan Cornilescu and condensed them into the app.yaml below. It seems to be working for my React SPA on GAE Standard. No application server (ex: serve.js, ExpressJS, etc) is necessary.

    env: standard
    runtime: nodejs10
    service: default
    
    handlers:
      - url: /static
        static_dir: build/static
    
      - url: /(.*\.(json|ico|js))$
        static_files: build/\1
        upload: build/.*\.(json|ico|js)$
    
      - url: .*
        static_files: build/index.html
        upload: build/index.html
    

提交回复
热议问题