Angular 6 routes not found on Google App Engine

前端 未结 3 985
予麋鹿
予麋鹿 2021-01-16 01:49

I deployed an Angular 6 application on Google App Engine. The app.yaml config looks like that:

runtime: python27
api_version: 1
threadsafe: true

skip_files:         


        
3条回答
  •  隐瞒了意图╮
    2021-01-16 02:01

    Compiled and deployed Angular applications contain of a single index.html along with a couple of assets, such as JavaScript files. The index file contains all JavaScript files. Routing is performed virtually based on Angulars Router and not based on actual files. Therefore, your configuration can't resolve the routes like /route. Besides your assets, you have to redirect/rewrite all requests to your index.html in order to handle these by your Angular routing.

    runtime: python27
    api_version: 1
    threadsafe: true
    
    skip_files:
      - (?!^dist)
    
    handlers:
      - url: /(.*\.(js|css|svg|png)(|\.map))$
      static_files: dist/\1
      upload: dist/(.*)(|\.map)
      - url: /.*
      static_files: dist/index.html
      upload: dist/.*
    

    Please adapt the regular expression if you've got more files you're serving.

提交回复
热议问题