I have middleware which gets data from cookie (I use vue-cookies
).
try {
if (window.$cookies.get('region')) {
res.setHeader('Set-Cookie', [
`region=${window.$cookies.get('region')};path=/`
])
} else {
res.setHeader('Set-Cookie', [
`region=${process.env.DEFAULT_REGION};path=/`
])
}
} catch (e) {
console.log(e)
}
Everything works correctly, but in server terminal I got that:
ReferenceError: window is not defined
at server.js:3102:7
at promisify (server.js:2522:15)
at middlewareSeries (server.js:2501:10)
at server.js:2502:12
at async module.exports../.nuxt/server.js.__webpack_exports__.default (server.js:1964:3)
Should I just leave it be, or there is opportunity to fix it?
Ok, to get access to this field I just used req.cookies.region
Thanks for help everyone!