Cookie is destroyed once I switch the page

My program logs in (in login.html) and the express session cookie is created. Once the page is switched to index.html, the cookie is lost. I am using the live port extension running of port 5500 vscode and I am using node with mongo running on port 3000.

Here is the code snippet.


  const corsOptions = {
    origin: 'http://127.0.0.1:5500', // Set to your frontend's origin
    credentials: true, // To allow cookies and sessions
  };


const app = express();
app.use(cors(corsOptions));
app.options('*', cors(corsOptions));
app.use(express.json());
app.use(cookieParser());
app.use(session({
  secret: 'secret',
  resave: false,
  saveUninitialized: true,
  cookie: {
    path: '/',
    httpOnly: false, //cahnge later to true
    secure: false, // For development. Use 'true' for production with HTTPS.
    sameSite: 'none',
    maxAge: 1000 * 60 * 60 * 24 * 365
  }
}));

I have tried adding the path, changing the sameSite to Lax, changing the max age, adding credentials. To add on, my back end works perfectly fine with Thunder Client. The cookie is stored and I can use a post to retrieve the user data.