unenv icon indicating copy to clipboard operation
unenv copied to clipboard

Accessing CallContext from handlers

Open SegaraRai opened this issue 3 years ago • 1 comments

CallContext, which is the argument of the handler created by createCall, can have additional properties, but those properties are not passed to the actual handler (such as h3 app) and are not accessible.

Cloudflare Workers, for example, may need access to event and I want a way to access this. https://github.com/unjs/nitro/blob/v0.4.4/src/runtime/entries/cloudflare.ts#L26

One suggested solution is to add context prop to req. (req as any)._callContext = context, or (req as any)[symCallContext] = context (using symbol)

SegaraRai avatar May 13 '22 10:05 SegaraRai

May not needed when unjs/h3#73 is done.

SegaraRai avatar May 13 '22 11:05 SegaraRai