// middlewares
#5869
Replies: 1 comment 2 replies
-
Do you solve it? I have the same issue with my auth middleware |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
app.use(cors());
app.use(cookieParser());
app.use(express.json());
this is servers.js file.
const googleAuth = async (req, res, next) => {
const { name, email, img } = req.body;
try {
// check if user exists or not
const user = await User.findOne({ email });
} catch (error) {
console.log(error);
res.status(400);
return next(error);
}
};
module.exports = {
loginUser,
signupUser,
googleAuth,
};
above code is from auth.js file //controllers
const jwt = require("jsonwebtoken");
const protect = async (req, res, next) => {
try {
// Get token from header
const token = req.cookies.access_token;
} catch (error) {
res.status(401);
return next(new Error("Not authorized"));
}
};
module.exports = protect;
above code is from auth.js //middlewares
but still i am not able to set cookies help me
Originally posted by @Abhiie in #4907 (comment)
Beta Was this translation helpful? Give feedback.
All reactions