nitro icon indicating copy to clipboard operation
nitro copied to clipboard

Request context is empty via plugin's hook when deployed on Cloudflare

Open nasyrov opened this issue 1 year ago • 1 comments

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?

nasyrov avatar Feb 26 '24 23:02 nasyrov

I can hook into the request and add things to the context. The problem I'm having is that the close hook never happens.

Gerbuuun avatar Mar 15 '24 21:03 Gerbuuun