应用程序引擎App.yaml变量子目录



这是我当前的app.yaml:

runtime: nodejs10
service: default
instance_class: F1
automatic_scaling:
min_instances: 0
max_instances: 2
handlers:
# Serve extension from where they were requested
- url: /(.*.(css|ico|js|png|jpg|gif|mp4|txt|xml|json))$
static_files: dist/apps/my-app/browser/1
upload: dist/apps/my-app/browser/.*.(css|ico|js|png|jpg|gif|mp4|txt|xml|json)$
secure: always
expiration: "365d"
# Handle blog SEO routes
- url: /blog
static_files: dist/apps/my-app/browser/blog/index.html
upload: dist/apps/my-app/browser/blog/index.html
secure: always
expiration: "0s"
- url: /blog/introducing-my-app
static_files: dist/apps/my-app/browser/blog/introducing-my-app/index.html
upload: dist/apps/my-app/browser/blog/introducing-my-app/index.html
secure: always
expiration: "0s"
- url: /blog/added-international-support
static_files: dist/apps/my-app/browser/blog/added-international-support/index.html
upload: dist/apps/my-app/browser/blog/added-international-support/index.html
secure: always
expiration: "0s"
- url: /blog/new-blog-entry
static_files: dist/apps/my-app/browser/blog/new-blog-entry/index.html
upload: dist/apps/my-app/browser/blog/new-blog-entry/index.html
secure: always
expiration: "0s"
# Handle default index.html
- url: /(.*)
static_files: dist/apps/my-app/browser/index.html
upload: dist/apps/my-app/browser/index.html
secure: always
expiration: "0s"

我怎样才能把";处理博客SEO路线"遵守一条规则?用每个博客条目更新app.yaml是不可扩展的。

此结构是从Angular Universal预渲染项目生成的。

我尝试了一些组合,但没有运气:

- url: /blog/(.*)
static_files: dist/apps/my-app/browser/blog/1/index.html
upload: dist/apps/my-app/browser/blog/1/index.html
secure: always
expiration: "0s"

我认为您的最后一次尝试与实际解决方案非常接近。请简单地调整upload值:

- url: /blog/(.*)
static_files: dist/apps/my-app/browser/1/index.html
upload: dist/apps/my-app/browser/(.*)/index.html
secure: always
expiration: "0s"

正如您在Google Cloud文档中描述upload密钥时所看到的,您需要在其定义中提供regex占位符,而不是反向引用。

请考虑在SO中复习类似的问题,比如这个或这个。

最新更新