【问题标题】:AppEngine Static Files with Express/NodeJS使用 Express/NodeJS 的 AppEngine 静态文件
【发布时间】:2020-01-22 12:32:39
【问题描述】:

我正在尝试通过 AppEngine 上的 express 提供静态应用程序和 API。点击 app.com/* 应该会将您带到公共目录,但 app.com/v1/ 应该会点击终点。

我的问题是 code in the docs 似乎对我不起作用,即使我完全禁用 express。

我的目录结构如下:

app
--src
---v1
--public
---index.html
--app.yaml

但是将它放在 yaml 中(暂时忽略 API)

handlers:
  - url: /static
      static_dir: public
  - url: /.*
      secure: always
      redirect_http_response_code: 301
      script: auto

访问应用时返回 502。

有什么想法吗?

【问题讨论】:

  • 您好,您可以在请求app.com/ 时在 Stackdriver Logging 中分享您应用的日志吗?这可能与编码问题有关,以免开始放弃可能性。
  • 嗨!堆栈驱动程序没有警告/错误,尝试访问应该在该公共目录中的文件时只有 502 响应。

标签: node.js express google-app-engine


【解决方案1】:

我已经按照您分享的文档快速入门,刚刚将以下条目添加到app.yaml

handlers: - url: /static static_dir: public -url: /(.*) static_files: public/\1 upload: public/(.*) - url: /.* secure: always redirect_http_response_code: 301 script: auto

然后,尝试使用https://xxxx.appspot.com/index.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-28
    • 2015-02-26
    • 1970-01-01
    • 2018-11-26
    • 2017-10-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多