Nuxt Auth Utils
I have a server middleware. If the user isn't authorised I want to store the requested url in the session and redirect to the login page. On successful login I want to redirect to the requested url. In my server middleware I'm trying to call setUserSession however I'm seeing the error message
ERROR [unhandledRejection] Cannot set headers after they are sent to the client 10:53:55 AM
at ServerResponse.setHeader (node:_http_outgoing:659:11)
at setCookie (node_modules/.pnpm/h3@1.15.3/node_modules/h3/dist/index.mjs:610:20)
at updateSession (node_modules/.pnpm/h3@1.15.3/node_modules/h3/dist/index.mjs:1424:5)
at async Object.update (node_modules/.pnpm/h3@1.15.3/node_modules/h3/dist/index.mjs:1338:7)
at async setUserSession (.nuxt/dev/index.mjs:2548:3)
ERROR [unhandledRejection] Cannot set headers after they are sent to the client 10:53:55 AM
at ServerResponse.setHeader (node:_http_outgoing:659:11)
at setCookie (node_modules/.pnpm/h3@1.15.3/node_modules/h3/dist/index.mjs:610:20)
at updateSession (node_modules/.pnpm/h3@1.15.3/node_modules/h3/dist/index.mjs:1424:5)
at async Object.update (node_modules/.pnpm/h3@1.15.3/node_modules/h3/dist/index.mjs:1338:7)
at async setUserSession (.nuxt/dev/index.mjs:2548:3)
