'Why my session are not setting on my network?

I'm currently working on my sessions for my app. Whenever i use the link

TAKE NOTE OF MY LINKS

as you can see on my localhost:3000/login after logging in my cookies and sessions are being set successfully. Localhost Link

This are my cookies after logging in successfully. Cookies

HOWEVER, when i wanted to access my app on the built server and after logging in.

My sessions are not able to persists on the cookies tab.

Network Cookies not showing

Network build

This is my code on setting the session for users

app.use(
  cors({
    // Change the origin to
    // 192.168.254.100
    //DEPENDS ON YOUR LOCAL NETWORK OR
    // localhost
    //origin: ["http://localhost:3000"],
    origin: ["http://192.168.254.100:3000"],
    methods: ["GET", "POST", "PUT", "DELETE"],
    credentials: true,
    optionSuccessStatus: 200,
  })
);

app.use(
  session({
    key: "userId",
    secret: "subscribe",
    resave: false,
    saveUninitialized: false,
    cookie: {
      maxAge: 24 * 60 * 60 * 1000,
    },
  })
);

this is my routes on setting the session:

    app.get("/login", (req, res) => {
  if (req.session.user) {
    res.send({ loggedIn: true, user: req.session.user });
  } else {
    res.send({ loggedIn: false });
  }
});


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source