Skip to content

Instantly share code, notes, and snippets.

@davidcsejtei
Created October 16, 2020 09:17
Show Gist options
  • Select an option

  • Save davidcsejtei/1e0d63c9372becce903cfd8a8174d589 to your computer and use it in GitHub Desktop.

Select an option

Save davidcsejtei/1e0d63c9372becce903cfd8a8174d589 to your computer and use it in GitHub Desktop.
import { NextFunction, Request, Response } from 'express';
const authorizationMiddleware = (request: Request, response: Response, next: NextFunction): void => {
if (!request.headers || !request.headers['authorization']) {
response.statusCode = 403;
response.json({ error: "Missing JWT token from the 'Authorization' header" });
} else {
next();
}
};
export default authorizationMiddleware;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment