【问题标题】:Google App Engine ignores context pathGoogle App Engine 忽略上下文路径
【发布时间】:2018-03-30 11:04:13
【问题描述】:

我的 app.yaml 中有以下上下文路径处理程序:

runtime: nodejs
env: flex

resources:
  cpu: 1
  memory_gb: 1
  disk_size_gb: 20

handlers:
- url: /api
  secure: always
  script: app.js

- url: /
  secure: always
  static_dir: public

静态工作正常。我有两个问题:

secure: always

pragma 无法按预期工作。没有从 http 到 https 的重定向。

其次,我的 NodeJS 应用中有 /test 端点。但是 /api/test 是 404,但是 /test 可以工作,忽略 /api

我做错了什么?

生成的运行时配置:

runtime: nodejs
api_version: '1.0'
env: flexible
threadsafe: true
handlers:
  - url: /api
    script: app.js
    secure: always
  - url: '/(.*)'
    secure: always
    application_readable: false
    static_files: "public/\\1"
    require_matching_file: false
    upload: 'public/.*'
automatic_scaling:
  min_num_instances: 2
  max_num_instances: 20
  cpu_utilization:
    target_utilization: 0.5
resources:
  cpu: 1
  memory_gb: 1
  disk_size_gb: 20

【问题讨论】:

    标签: google-app-engine


    【解决方案1】:

    this answer 中所述,flex 环境不支持 app.yaml 中的 handlers 部分。那篇文章还提供了几个示例,说明如何在 nodejs 中启动并运行它。

    你问题的后半部分有一个类似的答案——你需要直接在你的节点应用中实现这些重定向。

    【讨论】:

      猜你喜欢
      • 2022-01-25
      • 1970-01-01
      • 2012-11-15
      • 2015-12-16
      • 2019-09-13
      • 2019-05-17
      • 2012-10-05
      • 2019-04-22
      • 2017-09-24
      相关资源
      最近更新 更多