angulargoogle-app-enginehtml5mode

Angular html5 mode with Google Cloud App Engine


I'm deploying my Angular 7 app on Google Cloud (App Engine).

The app is working fine, but I've some questions...

First of all is how to handle html5 mode, so that when I'm on a route (e.g https://myapp.com/my-route/) and I refresh the browser, the server should reply my the index.html, and the angular should perform the routing, instead of returning a 404 error page.

How can I do that? Can you help me?

Thanks so much!


Solution

  • Here is my app.yaml, it's working fine, if you have any tips please share :)

    runtime: python27
    threadsafe: true
    
    skip_files:
    - ^(?!dist)
    
    handlers:
    - url: /en/(.*\.(gif|png|jpg|css|js)(|\.map))$
      static_files: dist/en/\1
      upload: dist/en/(.*)(|\.map)
    
    - url: /it/(.*\.(gif|png|jpg|css|js)(|\.map))$
      static_files: dist/it/\1
      upload: dist/it/(.*)(|\.map)
    
    - url: /en/(.*)
      static_files: dist/en/index.html
      upload: dist/en/index.html
    
    - url: /it/(.*)
      static_files: dist/it/index.html
      upload: dist/it/index.html
    
    - url: /
      static_files: dist/en/index.html
      upload: dist/en/index.html
    
    error_handlers:
    - file: index.html