Saturday, January 6, 2024
HomeiOS Developmentjavascript - Token Cookie Not Setting on iOS (Safari) - Vite +...

javascript – Token Cookie Not Setting on iOS (Safari) – Vite + React Shopper, Specific.js Server


I’ve developed an utility utilizing Vite + React for the consumer facet and Specific.js for the server facet. The login performance works seamlessly on computer systems and Android gadgets. Nevertheless, I encountered a problem when trying to log in from Safari on iOS. After thorough testing, it seems that the token cookie shouldn’t be being set when verifying the login standing (solely in iOS).

After verifying username and password I do that

const token = createAccessToken(consumer);
  res.cookie("token", token, {
    maxAge: 315360000,
    sameSite: "None",
    safe: true,
  });
  return res.standing(200).json(consumer);

Then to validate the token on the server I do that

validateToken(token)
  .then((consumer) => {
    return res.standing(200).json(consumer);
  })
  .catch(() => {
    return res.standing(401).json({ message: "Token invalido o expirado" });
  });

Lastly, my CORS choices

const corsOptions = {
  origin: [
    "http://localhost:5173",
    "https://some_url.vercel.app",
    "http://192.mi_ip:19006",
  ],
  strategies: "GET,HEAD,PUT,PATCH,POST,DELETE",
  credentials: true,
  optionsSuccessStatus: 204,
};

Server constantly returns a 401 error, and after in depth testing, it is evident that the token shouldn’t be current. It is necessary to notice that the applying works flawlessly on different platforms.

The consumer is hosted on Vercel, and the server is on Fly.io. I am particularly encountering this subject on iOS (Safari).

Any insights or options on why the token cookie may not be setting on iOS can be enormously appreciated. Thanks!



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments