python-2.7 - 部署 Angular 7 网站和谷歌应用引擎 API 时的应用 yaml 配置问题
问题描述
我正在尝试在 Google App Engine 中部署一个 Angular7 应用程序,并在 python2.7 中使用后端端点。在这里我收到处理程序错误:
找不到处理程序引用的静态文件:dist/_ah/api/sampleApi/v1/users
在 app.yaml 中配置时,Angular 的 dist 文件夹和 API 都会失败。
如果从 app.yaml 中删除 API 的配置,则 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)
解决方案
我通过在我的 app.yaml 文件中添加两个额外的处理程序来解决这个问题:
- url: /(..(html|gif|png|jpg|js))$
static_files: dist/\1
上传: dist/. .(html|gif|png|jpg|js)$
安全:总是 - url:/img
static_dir:dist/assets
安全:总是
它现在正在工作。
推荐阅读
- elasticsearch - 在 Elastic Search 中使用嵌套字段执行多字段/多维聚合
- symfony - EasyAdmin (v2):按相关实体的属性过滤列表视图
- php - SqlServerParser.php 不符合 Crestapps 中的 psr-4 自动加载标准
- sas - 将 500000 秒转换为 HH:MM:SS
- javascript - Mongoose 在架构级别排除文档结果
- python - 如何解决元组列表中的列表索引超出范围?
- javascript - iframe 中的 Pdf blob url 无法在移动设备和平板电脑上加载,但在所有主要桌面浏览器上都可以正常工作
- html - 定位这个孩子的特定父母兄弟姐妹
- reactjs - Axios - 尝试从数据库中删除用户时收到 404 错误
- javascript - 如何在应用程序中构建组件的“组合”?