Not able to access ctx.state.user in middleware

System Information
  • Strapi Version: 3.6.5
  • Operating System: Windows 10
  • Database: Postgres
  • Node Version: v14.17.3
  • NPM Version: 6.14.13
  • Yarn Version: 1.22.10

I need a middleware that runs on each and every route. I’m trying to get user state with ctx.state.user but it’s undefined always

This is how i’ve loaded middleware

module.exports = {
  load: {
    after: ["rbac"],
  },
};

I do think there’s some issue with how i’m loading the middleware, can anyone please help me with it.

1 Like

I have the same issue, if a console.log ctx.state it only shows session:{}