我在我的快速API中使用中间件来验证auth0
const checkJwt = jwt({
// Dynamically provide a signing key based on the kid in the header and the singing keys provided by the JWKS endpoint.
secret: jwksRsa.expressJwtSecret({
cache: true,
rateLimit: true,
jwksRequestsPerMinute: 5,
jwksUri: `https://${process.env.AUTH0_DOMAIN}/.well-known/jwks.json`
}),
// Validate the audience and the issuer.
audience: process.env.AUTH0_AUDIENCE,
issuer: `https://${process.env.AUTH0_DOMAIN}/`,
algorithms: ['RS256']
});
…
server.use('/api', checkJwt, routes);
它适用于我的本地开发机器,但是当我在生产中运行它时,我得到:
Error: getaddrinfo ENOTFOUND undefined undefined:443
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
我在生产中运行ubuntu 12,在dev上运行mac.
解决方法:
您似乎忘记在生产系统上设置AUTH0_DOMAIN环境变量.
根据github的示例,您的代码是正确的,
但是在这个例子中有一节如何运行这个代码与许多环境变量设置.
DEBUG = express,jwks JWKS_HOST = https:// my-authz-server AUDIENCE = urn:my-resource-server ISSUER = https:// my-authz-server / node server.js.
请在启动应用程序之前检查您的生产配置.
原文地址:https://codeday.me/bug/20190608/1196847.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。