Express JWT timesout when validating a JWT (with RSA)

in my express code below, the app never gets to the endpoint logic (e.g. /ahealth or /graphql) and my token is valid according to jwt.io. What should I be looking for when experiencing this timeout?

thanks

import * as express from "express";

import * as bodyParser from "body-parser";
import * as cors from "cors";

import * as jwt from "express-jwt";
import * as jwksRsa from "jwks-rsa";

import * as graphqlHTTP from "express-graphql";

import "reflect-metadata";

import ElysiiGraphQlSchema from "./src/schema";

const app = express();

const credentialsRequired = (process.env.production === "true");

app.get("/health", (req, res) => {
    return res.status(200).send("health");
});

app.use((req, res, next) => {
    console.log(req.headers);
    next();
});

// Authentication middleware. When used, the
// access token must exist and be verified against
// the Auth0 JSON Web Key Set
const checkJwt = jwt({
    // Dynamically provide a signing key
    // based on the kid in the header and
    // the signing keys provided by the JWKS endpoint.
    secret: jwksRsa.expressJwtSecret({
        cache: true,
        jwksRequestsPerMinute: 5,
        jwksUri: `https://elysiirings.auth0.com/.well-known/jwks.json`,
        rateLimit: true,
    }),

    // Validate the audience and the issuer.
    algorithms: "RS256"],
    audience: "https://gq4lyd4mdj.execute-api.us-west-2.amazonaws.com/prod/graphql",
    issuer: `https://elysiirings.auth0.com/`,
});

app.use(checkJwt);

app.get("/ahealth", (req, res) => {
    return res.status(200).send("authenticated-health");
});

// allow incoming form data and json requests
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());

app.use(cors());

app.listen(3000);

app.use(
    "/graphql",
    graphqlHTTP((request: any) => {
        return {
            context: {
                user: request.auth && request.auth.sub,
            },
            graphiql: true,
            schema: ElysiiGraphQlSchema,
        };
    }),
);

export default app;
1 Like

I’m having the same issue @nick_elysii, did you manage to resolve it?

Hey there!

Sorry for such huge delay in response! We’re doing our best in providing you with best developer support experience out there, but sometimes our bandwidth is not enough comparing to the number of incoming questions.

Wanted to reach out to know if you still require further assistance?