nitro
nitro copied to clipboard
Request context is empty via plugin's hook when deployed on Cloudflare
Describe the feature
Request context is empty when Nitro deployed with Cloudflare:
export default defineNitroPlugin((nitro) => {
nitro.hooks.hook("request", ({ context }) => {
console.log(context) // it's empty
})
})
Unlike middleware context contains all the necessary data:
export default defineEventHandler(({ context }) => {
console.log(context) // contains all the necessary data
})
I would love to use plugins to configure different services like database connection etc, for now I'm using middleware but it feels a bit wrong imho.
Thanks!
Additional information
- [ ] Would you be willing to help implement this feature?
I can hook into the request and add things to the context. The problem I'm having is that the close
hook never happens.