Static GitHub Issues

[383] How to pass request.currentUser to context.req in Nuxt framework

prev: Use BabiliPlugin() instead of UglifyJs()
next: Multiple error pages

Hello. could you help me? I use a bunch of AdonisJS + Nuxt.js. On the server, when I call request

request.currentUser // {id: '10215478' name: 'Alex' ...}
request.auth.check() // true

How can I pass these parameters to Nuxt framework? I tried to use nuxtServerInit:

// resources/store/index.js
export const state = {
  currentUser: null,
}

export const mutations = {
  SET_USER: function (state, user) {
    state.currentUser = user
  },
}

export const actions = {
  nuxtServerInit ({ commit }, { req }) {
    commit('SET_USER', req.currentUser) // req.currentUser = undefined
  },
}
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c334">#c334</a>)</em></sub></div>