File tree Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -166,8 +166,12 @@ export default defineNuxtModule<ModuleOptions>({
166166 nuxt . options . nitro . commands . preview = 'npx nuxthub preview'
167167 nuxt . options . nitro . commands . deploy = 'npx nuxthub deploy'
168168
169- // Add the env plugin
170- addServerPlugin ( resolve ( './runtime/env' ) )
169+ // Add the env middleware
170+ nuxt . options . nitro . handlers ||= [ ]
171+ nuxt . options . nitro . handlers . unshift ( {
172+ middleware : true ,
173+ handler : resolve ( './runtime/env' )
174+ } )
171175 }
172176
173177 // Local development without remote connection
Original file line number Diff line number Diff line change 1- import type { NitroAppPlugin } from 'nitropack'
2- import type { H3Event } from 'h3'
1+ import { eventHandler } from 'h3'
32
43// Hack around Cloudflare regression since nodejs_compat_v2 for process.env
5- export default < NitroAppPlugin > function ( nitroApp ) {
6- nitroApp . hooks . hook ( 'request' , async ( event : H3Event ) => {
7- const env = event . context . cloudflare ?. env || { }
8- for ( const key in env ) {
9- process . env [ key ] = env [ key ]
10- }
11- } )
12- }
4+ export default eventHandler ( ( event ) => {
5+ const env = event . context . cloudflare ?. env || { }
6+ for ( const key in env ) {
7+ process . env [ key ] = env [ key ]
8+ }
9+ } )
You can’t perform that action at this time.
0 commit comments