@@ -15,6 +15,7 @@ import directoryListing from './utils/directoryListing';
1515
1616import { fileWatch , usePort , networkIps } from './utils/common' ;
1717import { existsSync } from 'node:fs' ;
18+ import Server from 'http-proxy' ;
1819
1920interface Options {
2021 root ?: string ;
@@ -27,7 +28,7 @@ interface Options {
2728 port ?: number ;
2829 host ?: string ;
2930 livereloadUrl ?: string ;
30- proxy ?: Record < string , string > ;
31+ proxy ?: Record < string , Server . ServerOptions > ;
3132 noDirListing ?: boolean ;
3233}
3334
@@ -59,11 +60,11 @@ export const servor = async ({
5960 port = await usePort ( undefined , host ) ;
6061 }
6162
62- const proxyConfig : Array < [ RegExp , string ] > = proxyConfigObj
63+ const proxyConfig : Array < [ RegExp , Server . ServerOptions ] > = proxyConfigObj
6364 ? Object . keys ( proxyConfigObj ) . map ( ( key ) => [ new RegExp ( key ) , proxyConfigObj ! [ key ] ] )
6465 : [ ] ;
6566
66- let proxy : { web : ( arg0 : any , arg1 : any , arg2 : { target : any ; changeOrigin : boolean } ) => any } ;
67+ let proxy : { web : ( arg0 : any , arg1 : any , arg2 : Server . ServerOptions ) => any } ;
6768
6869 // Configure globals
6970
@@ -183,9 +184,9 @@ export const servor = async ({
183184 const serveRoute = async ( req : http2 . Http2ServerRequest , res : http2 . Http2ServerResponse , pathname : string ) => {
184185 try {
185186 for ( let i = 0 ; i < proxyConfig . length ; i ++ ) {
186- const [ key , value ] = proxyConfig [ i ] ;
187+ const [ key , options ] = proxyConfig [ i ] ;
187188 if ( key . test ( pathname ) && proxy ) {
188- return proxy . web ( req , res , { target : value , changeOrigin : true } ) ;
189+ return proxy . web ( req , res , options ) ;
189190 }
190191 }
191192 const index = staticMode ? path . join ( root , pathname , fallback ) : path . join ( root , fallback ) ;
0 commit comments