部署 angular 7 网站和 google 应用引擎 API 时的应用程序 yaml 配置问题

App yaml configuration issue when deploying angular 7 website and google app engine API's

我正在尝试在 Google App Engine 中部署一个 Angular7 应用程序,后端端点在 python2。7.And 这里我收到处理程序错误:

Static file referenced by handler not found: dist/_ah/api/sampleApi/v1/users

Angular dist 文件夹和 API 在 app.yaml 中配置时都失败了。

如果从 app.yaml Angular 网站中删除 API 的配置,则可以正常工作。 如果 Angular dist 从邮递员 app.yaml API 的工作中删除。

handlers:     
- url: /        
  static_files: dist/index.html         
  upload: dist/index.html      
  secure: always       
- url: /       
  static_dir: dist      
- url: /_ah/api/.*    
  script: sample.api   

我的项目结构是:

project-folder   
   -- app.yaml    
   -- endpoint source code files    
   -- dist folder (for angular)    

我通过向我的 app.yaml 文件添加两个额外的处理程序来解决这个问题:

  • url: /(..(html|gif|png|jpg|js))$
    static_files: 距离/\1
    上传:dist/.
    .(html|gif|png|jpg|js)$
    安全:总是
  • url: /img
    static_dir: dist/assets
    安全:总是

现在可以使用了。