koajs / session

Simple session middleware for koa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot overwrite session in Koa/next.js

julien-mamalian opened this issue · comments

I'm using koa, koa-session, koa-router and next.js.

When I auth, I initialize session here ctx.session.subscriber = false

I'm trying to update the session inside a route and share the new value across all routes (which is the aim of a session)

router.put('/api/test', async (ctx, next) => {
     ctx.session.subscriber = true;
     ctx.status = 200;
     ctx.body = {subscriber: true}
})

When I make a call to another route after edtiing session in "api/test", the session still has the initial value (ctx.session.subscriber is false again). We do not change the value elsewhere in the code.

Any idea on how to solve this ? Is it an issue with koa-session + next.js ?

Thank you for your help.