Express-Session cookie not set if secure

I am using express-session and when setting the cookies secure property to true the cookie doesn’t set. The connection is in https.

Here is the code used to set the middleware

app.use(
  session({
    cookie: {
      path: "/",
      httpOnly: true,
      maxAge: null,
      secure: true
    },
    store: new memoryStore({
      checkPeriod: 86400000
    }),
    resave: false,
    saveUninitialized: true,
    secret: process.env.COOKIE_SECRET,
    name: "SESSION:ID"
  })
);

Hey @LukaGamingDev,

That’s strange because I’m using express-session and it works well.

And I’m moving this to #coding-help!

Typo :grin::slightly_smiling_face:

From the express-session documentation:

If you have your node.js behind a proxy and are using secure: true, you need to set “trust proxy” in express.

As I understand it Glitch routes web traffic to your container through their proxy so I believe this would apply. Try adding app​.​set​(​'​trust proxy​'​, ​1​) to your project’s express initialization.

Your solution worked! thanks