Fixed cookie issue
This commit is contained in:
@@ -65,12 +65,12 @@ const loginUser = catchAsyncErrors(async (req, res) => {
|
|||||||
|
|
||||||
return res
|
return res
|
||||||
.status(200)
|
.status(200)
|
||||||
.cookie(process.env.TOKEN_NAME, token, {
|
.cookie("uid", token, {
|
||||||
|
httpOnly: true, // Prevent access from JavaScript (recommended for security)
|
||||||
|
secure: false, // ⚠️ Set to `false` for localhost
|
||||||
|
sameSite: "Lax", // Use "Lax" instead of "None" for better compatibility
|
||||||
path: "/",
|
path: "/",
|
||||||
sameSite: "None",
|
expires: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // 7 days
|
||||||
secure: process.env.NODE_ENV === "production",
|
|
||||||
httpOnly: true,
|
|
||||||
expires: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
|
|
||||||
})
|
})
|
||||||
.json({
|
.json({
|
||||||
success: true,
|
success: true,
|
||||||
@@ -260,8 +260,6 @@ const resetPassword = catchAsyncErrors(async (req, res) => {
|
|||||||
|
|
||||||
// get user personal details
|
// get user personal details
|
||||||
const getUserDetails = catchAsyncErrors(async (req, res) => {
|
const getUserDetails = catchAsyncErrors(async (req, res) => {
|
||||||
|
|
||||||
|
|
||||||
const user = await User.findById(req.user._id);
|
const user = await User.findById(req.user._id);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
|||||||
Reference in New Issue
Block a user