-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Hi,there is an issue, please help.
My project is nuxt2, use the version of 2.2.1. in my local env, it works fine, but when deployed to line, we often get the issue.
my case is I set cookie in nuxtInitializeState.
ERROR Cannot set headers after they are sent to the client
07:15:54 at ServerResponse.setHeader (_http_outgoing.js:558:11)
07:15:54 at p (node_modules/cookie-universal/dist/cookie-universal-common.js:1:1337)
07:15:54 at Object.set (node_modules/cookie-universal/dist/cookie-universal-common.js:1:1774)
07:15:54 at Object.module.exports.prop.setCookies (utils/nuxtInitializeState.js:327:0)
07:15:54 at server.js:2991:14
07:15:54 at Initialize.each (utils/nuxtInitializeState.js:356:0)
07:15:54 at Initialize.syncCookies (utils/nuxtInitializeState.js:365:0)
07:15:54 at Initialize.setup (utils/nuxtInitializeState.js:657:0)
07:15:54 at processTicksAndRejections (internal/process/task_queues.js:93:5)
07:15:54 at async Store.nuxtServerInit (store/index.js:30:0)
export const actions = { async nuxtServerInit(store, context) { await new Initialize(store, context).setup("server"); } }
in class Initialize , I have some task to init the state, some tasks are promise, so I have to set await.
one of task(syncCookies) is to get the data from api, then the set it to cookie.
could you please give me a favor?