POST request awaits endlessly

Asked

Viewed 25 times

0

When I add the authentication in the post route and send the request, the request is waiting endlessly

AUTH ARCHIVE:

const jwt = require("express-jwt");
const secret = require("../config").secret;

function getTokenHeader(req){
    if(!req.headers.authorization) return null;
    const token = req.headers.authorization.split(" ");
    if(token[0] !== "bearer") return null;
    return token[1];
}

const auth = {
    required: jwt({
        secret,
        userProperty: 'payload',
        getToken: getTokenHeader
    }),
    optional: jwt({
        secret,
        userProperty: 'payload',
        credentialsRequired: false,
        getToken: getTokenHeader
    })
};

module.exports = auth;
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.