[Vuejs]-How to access req.session in nextServerInit before rendering

0👍

you need to add this in your server/index.js or server/app.js basically wherever you create your express instance

// Create express router
const router = express.Router()

// Transform req & res to have the same API as express
// So we can use res.status() & res.json()
router.use((req, res, next) => {
  Object.setPrototypeOf(req, app.request)
  Object.setPrototypeOf(res, app.response)
  req.res = res
  res.req = req
  next()
})

Leave a comment