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
My cookies get included in local environment when i include credentials but not in production
Am doing all this in "use client"
Additional information
BACKEND////////////////constcorsOptions={origin: process.env.FRONTEND_URL,credentials: true,methods: ["GET","POST","PUT","DELETE","OPTIONS"],};constcheckAdminCredentials=(req,res,next)=>{console.log("All cookies:",req.cookies);// Log all cookiesconsole.log("Headers:",req.headers);// Log all headersconstadminCookie=req.cookies["admin"];console.log("Admin cookie:",adminCookie);if(!adminCookie){returnres.status(401).json({error: "Unauthorized"});// 401 is more appropriate for auth}next();};app.use(express.json());app.use(cors(corsOptions));app.use(cookieParser());app.use("/admin",checkAdminCredentials);FRONTEND///////////////////////////setCookie("admin",true,{secure: true,sameSite: "None",path: "/",maxAge: 60*60*24*30,});constresponse=awaitfetch(process.env.NEXT_PUBLIC_BACKEND_SERVER+"/admin",{method: "GET",credentials: "include",});RESPONSE/////////401shouldbe200
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
My cookies get included in local environment when i include credentials but not in production
Am doing all this in "use client"
Additional information
Example
Response
401 should be 200
Beta Was this translation helpful? Give feedback.
All reactions