Angular 7 Routing in Google Cloud App Engine not working

后端 未结 1 1092
萌比男神i
萌比男神i 2021-02-20 10:37

I\'ve published an angular 7 Application to Google Cloud App Engine.

The index page is loading, but the subdirectorys give me

Error: Not Found
The reques         


        
1条回答
  •  清歌不尽
    2021-02-20 10:42

    I think your routing rules in handlers work fine if your resource files are only js and css. If you have image files, audio files, etc, you must use a more generic routing rule with regex:

    handlers:
      - url: /
        secure: always
        static_files: www/index.html
        upload: www/index.html
    
      #  Routing rules for resources, css, js, images etc. Any file with format filename.ext
      - url: /(.*\.(.+))$
        secure: always
        static_files: www/\1
        upload: www/(.*\.(.+))$
    
      #  Routing rule for Angular Routing
      - url: /(.*)
        secure: always
        static_files: www/index.html
        upload: www/index.html
    

    The idea is the same, but syntactically, a wild card match for any files with format filename.* will handle all the resource files.

    0 讨论(0)
提交回复
热议问题