File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ export default <NitroAppPlugin>function (nitroApp) {
3030 const request = new Request ( getRequestURL ( event ) ) as Request & {
3131 cf : typeof proxy . cf ;
3232 } ;
33-
3433 request . cf = proxy . cf ;
3534
3635 event . context . cloudflare = {
@@ -39,6 +38,15 @@ export default <NitroAppPlugin>function (nitroApp) {
3938 env : proxy . env ,
4039 context : proxy . ctx ,
4140 } ;
41+
42+ // Replicate Nitro production behavior
43+ // https://github.com/unjs/nitro/blob/main/src/runtime/entries/cloudflare-pages.ts#L55
44+ // https://github.com/unjs/nitro/blob/main/src/runtime/app.ts#L120
45+ ( globalThis as any ) . __env__ = proxy . env ;
46+ ( event . node . req as any ) . __unenv__ = {
47+ ...( event . node . req as any ) . __unenv__ ,
48+ waitUntil : event . context . waitUntil ,
49+ } ;
4250 } ) ;
4351
4452 // https://github.com/pi0/nitro-cloudflare-dev/issues/5
You can’t perform that action at this time.
0 commit comments