Implement Basic Authentication Middleware (JWT)
Category: Web & App Development
Generate JavaScript code for an Express.js middleware function that verifies a JSON Web Token (JWT) sent in the 'Authorization' header (Bearer scheme). If the token is valid, it should attach the decoded payload to `req.user`. If invalid or missing, it should return a 401 or 403 error.
You can edit the prompt before copy
If you share the link prompt will be shared without your changes