File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 11import { fileURLToPath } from 'url'
22import { addServerHandler , addTemplate , defineNuxtModule , useLogger } from '@nuxt/kit'
33import type { Options } from 'http-proxy-middleware'
4- import { join } from 'pathe'
4+ import { resolve } from 'pathe'
55import { defu } from 'defu'
66// @ts -expect-error: No types
77import dedent from 'dedent'
@@ -21,19 +21,12 @@ export default defineNuxtModule<Options>({
2121 const runtimeDir = fileURLToPath ( new URL ( './runtime' , import . meta. url ) )
2222 nuxt . options . build . transpile . push ( runtimeDir , '#build/proxy-handler' )
2323
24- const handlerPath = join ( nuxt . options . buildDir , 'proxy-handler.ts' )
25-
2624 // Final resolved configuration
2725 const finalConfig = nuxt . options . runtimeConfig . proxy = defu ( nuxt . options . runtimeConfig . proxy , {
2826 logger : options . logger ,
2927 changeOrigin : options . changeOrigin ,
3028 } )
3129
32- addServerHandler ( {
33- handler : handlerPath ,
34- middleware : true ,
35- } )
36-
3730 addTemplate ( {
3831 src : 'proxy-handler.ts' ,
3932 write : true ,
@@ -43,6 +36,11 @@ export default defineNuxtModule<Options>({
4336 export default createProxyMiddleware(${ finalConfig } )
4437 ` ,
4538 } )
39+
40+ addServerHandler ( {
41+ handler : resolve ( nuxt . options . buildDir , 'proxy-handler.ts' ) ,
42+ middleware : true ,
43+ } )
4644 } ,
4745} )
4846
You can’t perform that action at this time.
0 commit comments