express-openid-connect: Authorization code flow results in "connect ECONNREFUSED 127.0.0.1:443"

Description

Hello, I am currently in the process of testing the upgrade path to 2.0.0 of this library using Auth0 as my oauth provider. After logging in to Auth0, the callback endpoint fails with the following error: BadRequestError: connect ECONNREFUSED 127.0.0.1:443 at /Users/hsostock/code/connect-web/node_modules/express-openid-connect/middleware/auth.js:105:31 at processTicksAndRejections (internal/process/task_queues.js:97:5)

Note: After doing some debugging, it appears that this is the result of an internal call to https://{auth0-domain}/.well-known/oauth-authorization-server returning a 404 Not Found error (which, for some reason, is surfaced as the above connection refused error).

Reproduction

I am using the following configuration in my express app:

const app = express();
app.use(oidc.auth({
  secret: "secret value",
  routes: {
    login: '/auth/login',
    logout: '/auth/logout',
    postLogoutRedirect: '/',
    callback: '/auth/callback',
  },
  session: {
    rolling: false,
    absoluteDuration: 60, // 60 seconds
  },
  authRequired: true,
  auth0Logout: true,
  clientID: "secret value",
  clientSecret: "secret value",
  baseURL: config.webUrl,
  issuerBaseURL: config.auth.issuerBaseURL,

  authorizationParams: {
    scope: 'openid profile email offline_access',
    response_type: 'code',
  },
}));

And occurs consistently (as mentioned) when validating the authorization code returned from Auth0.

Environment

  • Version of this library used: 2.0.0
  • Version of the platform or framework used, if applicable: Express 4.17.1
  • Other relevant versions (language, server software, OS, browser): Node.js 12.13.1 / Typescript / Chrome

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (6 by maintainers)

Most upvoted comments

Heads up if anyone else runs into this, its npm list agent-base, not node-agent-base which the repo name not the package name. tripped me up for a while.

Aha! It looks like I’m running a number of different versions of https-proxy-agent locally (all transitive) - and if I force them all to the latest version, it works again. So, looks like it’s actually on my side of things.