login endpoint:
res.header("authorization", accessToken).send(accessToken)
const user = await prisma.user.findFirst({
where: {
email: req.body.data.email,
},
});
const accessToken = jwt.sign(
user,
"my secret token there"
);
if (!user) return res.sendStatus(400).send("Email doesnt exist");
res.header("authorization", accessToken).send(accessToken)
router.get("/getAccountInfo", authenticateToken, getAccountInfo);
middleware authenticateToken :
export const authenticateToken = (
req: Request,
res: Response,
next: NextFunction
) => {
const authHeader = req.headers["authorization"];
...more code
}
authHeader is undefined
in login endpoint headers see authorization but middleware doesnt