Middleware redirect infinity loop & Vuex Data not updating #2308
Closed
Description
I'm using auth route with middleware and when using the below snippet the application going on a infinity loop.
export default function ({ store, redirect, error }) {
console.log('store.state.authUser',store.state.authUser);
if (store.state.authUser!=null) {
console.log('inside null')
redirect('/secret')
}
}
When clicking the link
The same route when accessed using direct url its working fine. But not when using
<nuxt-link to="/secret">Super secret page</nuxt-link>
Update:
Also the store.state.authUser
is globally accessible across different browser, when using with express.
Express Code below:
let config = require('./nuxt.config.js')
config.dev = !(process.env.NODE_ENV === 'production')
// Init Nuxt.js
const nuxt = new Nuxt(config)
// Build only in dev mode
if (config.dev) {
const builder = new Builder(nuxt)
builder.build()
}
// Give nuxt middleware to express
app.use(nuxt)