Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR Cannot set headers after they are sent to the client #157

Open
lswtianliang123 opened this issue Dec 7, 2023 · 0 comments
Open

ERROR Cannot set headers after they are sent to the client #157

lswtianliang123 opened this issue Dec 7, 2023 · 0 comments

Comments

@lswtianliang123
Copy link

lswtianliang123 commented Dec 7, 2023

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?

@microcipcip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant