Error: getaddrinfo ENOTFOUND undefined - checkJwt - docker

Hi,

I’m trying to use the next middleware in order to check the authentication token in a express node.js api rest app:

import jwt from “express-jwt”;
import JwksRsa from “jwks-rsa”;

export const checkJwt = jwt ({
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"]

});

When executing this middleware in a docker container (made it with docker compose) always have the error response:

500 Internal Server Error

Error: getaddrinfo ENOTFOUND undefined
   at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:69:26)

In the Docker compose file I’m listening in the port 3000
ports:
- “3000:3000”

have I to do any special configuration in order to use Auth0 in a Doker Container?

thanks for your help

Hi @carlos2 I had the same problem. And I didn’t understand what the problem was. Untill I realized process.env wasnt correct loaded.
So I had to add require(“dotenv”).config() in the top. Have you tried that? As what I can see in your example you are missing that part. Hope you find the solution!