Trying to pass data from middleware context.data = {id:1} to a function, not working :(

Hi, I have a middleware inside functions/api/_middleware.ts now I'm trying to pass some data from that middleware to a function like I want to access that data on onRequest(data) like that. right now, it returning an empty object.
1 Reply
James
James2y ago
This is a weird bug with how you set context.data: https://github.com/cloudflare/workers-sdk/issues/2797 Essentially, do context.data.id = 1 and it'll work, but if you override context.data entirely, it will not
GitHub
🐛 BUG: Pages middleware context.data not persisted if overwritten ·...
Which Cloudflare product(s) does this pertain to? Pages What version of Wrangler are you using? 2.11.1 What operating system are you using? Windows 10 Describe the Bug Originally reported on the Co...
Want results from more Discord servers?
Add your server