File tree 2 files changed +13
-12
lines changed
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>({
166
166
nuxt . options . nitro . commands . preview = 'npx nuxthub preview'
167
167
nuxt . options . nitro . commands . deploy = 'npx nuxthub deploy'
168
168
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
+ } )
171
175
}
172
176
173
177
// 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'
3
2
4
3
// 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