here is the code for auth using jsonwebtoken which i got from youtube tutorial why req.user =user
import jwt from "jsonwebtoken";
const auth = (req, res, next) => {
try {
const token = req.header("Authorization");
if (!token) return res.status(400).json({ msg: "Invalid Authentication" });
jwt.verify(token, process.env.SECRET_JWT, (err, user) => {
if
…
Top comments (1)
Hi :-) I have added an answer to your question. Let me know if anything is still unclear then I can update accordingly.