I try to build up a ssr project. So I use store in asyncData function as follow
async asyncData({ store, params, req }) {
if(process.server){
store.dispatch(...)
store.commit(...)
return {...}
}
}
It works great in client dev environment, it creates new store with new axios client for every request for server side render. But once I put it to lab, a container build up on aws, it goes wired. Request and session were different, but they shared the same store, and axios instance. So that make my data mess up.
lib: "nuxt": "^2.12.2", "axios": "^0.19.2",
========================= update 1 =========================
I got first point, once I build up and run locally, it ran in same result. before script:
"cross-env NODE_ENV=development backpack"
now script:
"cross-env NODE_ENV=production nuxt build"
"cross-env NODE_ENV=production backpack build"
"cross-env NODE_ENV=production node build/main.js"
if(process.server)
becauseasyncData
is always on server side - Ifaruki