greenlock-express: TypeError: greenlock.app is not a function

greenlock-express: TypeError: greenlock.app is not a function

我正在尝试 运行 我的 Express.js 使用 greenlock-express 使用此示例:

https://git.coolaj86.com/coolaj86/greenlock-express.js/src/branch/master/examples/production.js

但是我收到了这些错误:

[:80] Handling ACME challenges and redirecting to http2 (spdy/h2)
[:443] Serving http2 (spdy/h2)

[error] [greenlock.app] Your HTTP handler had an uncaught error:

TypeError: greenlock.app is not a function
    at //node_modules/greenlock-express/index.js:64:23

有谁知道示例失败的原因以及我应该如何解决它?

我是 greenlock 的作者,你的问题是两件事之一:

app 必须是函数

在您的 greenlock 配置中,您需要将 app 定义为 function (req, res) { ... }

例如:

greenlock.create({
  ...
, app: function (req, res) {
    require('./my-express-app.js')(req, res);
  }
})

必须导出 express 应用程序

var app = express();
...
module.exports = app;

观看(并关注)视频

如果您逐字执行此操作,您将拥有一个有效的配置,您将能够从那里更改它:

https://www.youtube.com/watch?v=e8vaR4CEZ5s&list=PLZaEVINf2Bq_lrS-OOzTUJB4q3HxarlXk

错误信息

我试图使错误信息非常清楚:

TypeError: greenlock.app is not a function
    at //node_modules/greenlock-express/index.js:64:23

当然,这对我来说很有意义,但显然对你来说不是 - 否则我们现在不会在这里。 :)

关于如何让它变得更好,你有什么建议吗?