You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Your production domains to your cors configuration
//Must remove "/" from your production URLapp.use(cors({origin: ["http://localhost:5173","https://cardoctor-bd.web.app","https://cardoctor-bd.firebaseapp.com",],credentials: true,}));
Let's create a cookie options for both production and local server
constcookieOptions={httpOnly: true,secure: process.env.NODE_ENV==="production",sameSite: process.env.NODE_ENV==="production" ? "none" : "strict",};//localhost:5000 and localhost:5173 are treated as same site. so sameSite value must be strict in development server. in production sameSite will be none// in development server secure will false . in production secure will be true
now we can use this object for cookie option to modify cookies
//creating Tokenapp.post("/jwt",logger,async(req,res)=>{constuser=req.body;console.log("user for token",user);consttoken=jwt.sign(user,process.env.ACCESS_TOKEN_SECRET);res.cookie("token",token,cookieOptions).send({success: true});});//clearing Tokenapp.post("/logout",async(req,res)=>{constuser=req.body;console.log("logging out",user);res.clearCookie("token",{ ...cookieOptions,maxAge: 0}).send({success: true});});
Deploy to Vercel
vercel
vercel --prod
- After completed the deployment . click on inspect link and copy the production domain
- setup your environment variables in vercel
- check your public API