部署 angular 7 网站和谷歌应用引擎 API 时的应用 yaml 配置问题 [英] App yaml configuration issue when deploying angular 7 website and google app engine API's

查看:21
本文介绍了部署 angular 7 网站和谷歌应用引擎 API 时的应用 yaml 配置问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to deploy an Angular7 application in Google App Engine with backend endpoints in python2.7.And here I am getting handlers error:

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

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

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

Both Angular dist folder and API's when configured in app.yaml fails.

如果从 app.yaml 中删除 API 的配置,Angular 网站就可以工作.如果 Angular dist 从 postman 的 app.yaml API 工作中删除.

If API's configuration is removed from app.yaml Angular website works. If Angular dist is removed from app.yaml API's work from the postman.

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 文件中添加另外两个额外的处理程序来解决这个问题:

I figured it out by adding two more extra handlers to my app.yaml file:

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

现在可以使用了.

这篇关于部署 angular 7 网站和谷歌应用引擎 API 时的应用 yaml 配置问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆