如何修复“ UnhandledPromiseRejection警告”

时间:2019-04-30 22:09:23

标签: node.js express openid okta okta-api

我正在使用Okta和Express设置登录和注册页面。我尝试设置ExpressOIDC,但随后出现此错误:

`App listening on port 3000
(node:15664) UnhandledPromiseRejectionWarning: RequestError: connect ECONNREFUSED 75.126.102.240:443
    at ClientRequest.req.once.err (Noicefilepath/index.js:182:22)
    at Object.onceWrapper (events.js:277:13)
    at ClientRequest.emit (events.js:194:15)
    at TLSSocket.socketErrorListener (_http_client.js:392:9)
    at TLSSocket.emit (events.js:189:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
(node:15664) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15664) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.`

ExpressOIDC的代码是:

const ExpressOIDC = require('@okta/oidc-middleware').ExpressOIDC;
const oidc = new ExpressOIDC({
    issuer: `${process.env.OKTA_ORG_URL}/oauth2/default`,
    client_id: process.env.OKTA_CLIENT_ID,
    client_secret: process.env.OKTA_CLIENT_SECRET,
    redirect_uri: `${process.env.HOST_URL}/authorization-code/callback`,
    appBaseUrl: process.env.HOST_URL, //the host url is http://localhost:3000
    scope: 'openid profile'
});

我该如何解决?任何帮助将不胜感激。

0 个答案:

没有答案