When I try to set cookies on my https site they aren't being set but they do get set on my localhost. I've been stuck on this for a week now and it has been hampering my development a lot please help:
// Set token in an HTTP-only cookie
res
.status(200)
.cookie("token", token, {
httpOnly: true,
secure: process.env.NODE_ENV === false,
domain:
process.env.NODE_ENV === "production"
? "Took website link out for privacy"
: "localhost",
path: "/",
sameSite: process.env.NODE_ENV === "production" ? "none" : "Lax",
expires: new Date(Date.now() + 24 * 60 * 60 * 1000), // 1 day
})
.json({
message: "Login successful",
data: {
email: user.email,
role: user.Role,
time_zone: user.time_zone,
Plan: user.Plan,
PlanExpiration: user.PlanExpiration,
PlanStatus: user.PlanStatus,
price_per_month: user.price_per_month,
currency: user.currency,
},
});
Here's my app.use setup. I took out my website links for both for privacy:
app.use(cookieParser());
console.log("Adjusted URL: ", adjustedUrl);
console.log("REACT_VIDEO_HANDLER_API_BASE_URL: ", REACT_VIDEO_HANDLER_API_BASE_URL);
app.use(
cors({
methods: ["GET", "POST", "PUT", "DELETE"],
allowedHeaders: ["Content-Type", "Authorization", "Access-Control-Allow-Origin"],
credentials: true,
})
);
app.use(express.json());
app.use((req, res, next) => {
next();
});