N
Nuxtβ€’10mo ago
Lannister

Best Practice for Logging Raw Headers on the First Request in Nuxt

I'm working on a Nuxt project and I need to log the raw headers, but I only want to do this on the first request. Currently, I have the following implementation:
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('request', (req) => {
console.log(req.node.req.rawHeaders) // log raw headers...
})
})
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('request', (req) => {
console.log(req.node.req.rawHeaders) // log raw headers...
})
})
However, this logs the raw headers for every request. How can I modify this code to only log the raw headers for the first request? Any insights or best practices on achieving this would be greatly appreciated. Thank you! πŸ™Œ
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server