【问题标题】:App yaml configuration issue when deploying angular 7 website and google app engine API's部署 Angular 7 网站和谷歌应用引擎 API 时的应用 yaml 配置问题
【发布时间】:2020-01-24 04:05:38
【问题描述】:

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

找不到处理程序引用的静态文件: dist/_ah/api/sampleApi/v1/users

在 app.yaml 中配置的 Angular dist 文件夹和 API 均失败。

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

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)    

【问题讨论】:

  • 您确定您引用的文件确实存在吗?

标签: python-2.7 google-app-engine google-cloud-platform angular7


【解决方案1】:

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

  • 网址:/(..(html|gif|png|jpg|js))$
    静态文件:dist/\1
    上传:dist/.
    .(html|gif|png|jpg|js)$
    安全:总是
  • 网址:/img
    静态目录:dist/assets
    安全:总是

现在可以了。

【讨论】:

    猜你喜欢
    • 2021-02-04
    • 1970-01-01
    • 1970-01-01
    • 2018-06-14
    • 1970-01-01
    • 1970-01-01
    • 2012-09-21
    • 1970-01-01
    相关资源
    最近更新 更多