@@ -78,13 +78,29 @@ function noProxyMatch(targetUrl) {
7878 if ( patternPort && patternPort !== port ) return false ;
7979
8080 if ( ! patternHost ) return false ;
81+
82+ // Support wildcard matching (e.g. 192.168.* or *.local)
83+ if ( patternHost . includes ( "*" ) ) {
84+ const regexStr = "^" + patternHost . replace ( / \. / g, "\\." ) . replace ( / \* / g, ".*" ) + "$" ;
85+ if ( new RegExp ( regexStr ) . test ( hostname ) ) return true ;
86+ }
87+
8188 if ( patternHost . startsWith ( "." ) ) {
8289 return hostname . endsWith ( patternHost ) || hostname === patternHost . slice ( 1 ) ;
8390 }
8491 return hostname === patternHost || hostname . endsWith ( `.${ patternHost } ` ) ;
8592 } ) ;
8693}
8794
95+ function isLocalAddress ( hostname : string ) : boolean {
96+ if ( hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" ) return true ;
97+ if ( hostname . startsWith ( "192.168." ) ) return true ;
98+ if ( hostname . startsWith ( "10." ) ) return true ;
99+ if ( hostname . match ( / ^ 1 7 2 \. ( 1 [ 6 - 9 ] | 2 \d | 3 [ 0 - 1 ] ) \. / ) ) return true ;
100+ if ( hostname . endsWith ( ".local" ) || hostname . endsWith ( ".lan" ) ) return true ;
101+ return false ;
102+ }
103+
88104function resolveEnvProxyUrl ( targetUrl ) {
89105 if ( noProxyMatch ( targetUrl ) ) return null ;
90106
@@ -111,6 +127,18 @@ function resolveEnvProxyUrl(targetUrl) {
111127}
112128
113129function resolveProxyForRequest ( targetUrl ) {
130+ let target ;
131+ try {
132+ target = new URL ( targetUrl ) ;
133+ } catch {
134+ target = null ;
135+ }
136+
137+ // Always bypass proxy for local/LAN addresses
138+ if ( target && isLocalAddress ( target . hostname . toLowerCase ( ) ) ) {
139+ return { source : "direct" , proxyUrl : null } ;
140+ }
141+
114142 const contextProxy = proxyContext . getStore ( ) ;
115143 if ( contextProxy ) {
116144 return { source : "context" , proxyUrl : proxyConfigToUrl ( contextProxy ) } ;
0 commit comments