File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,20 @@ export function setupGlobalFetch() {
4949 if ( typeof globalThis !== 'undefined' && globalThis . fetch && isEnabled && httpsAgent ) {
5050 const originalFetch = globalThis . fetch ;
5151 globalThis . fetch = async ( input : RequestInfo | URL , init ?: RequestInit ) => {
52+ // 将 input 转换为 URL 对象以检查 hostname
53+ let url : URL ;
54+ try {
55+ url = input instanceof URL ? input : new URL ( input . toString ( ) ) ;
56+ console . log ( 'url.hostname!!!!!!!!!!:' , url . hostname ) ;
57+ // 如果是内部服务地址,不使用代理
58+ if ( url . hostname === '172.17.0.1' ) {
59+ return originalFetch ( input , init ) ;
60+ }
61+ } catch ( error ) {
62+ console . warn ( 'URL parsing failed:' , error ) ;
63+ // URL 解析失败时使用默认代理配置
64+ }
65+
5266 const extendedInit : ExtendedRequestInit = {
5367 ...init ,
5468 agent : httpsAgent ,
@@ -57,4 +71,4 @@ export function setupGlobalFetch() {
5771 return originalFetch ( input , extendedInit as RequestInit ) ;
5872 } ;
5973 }
60- }
74+ }
You can’t perform that action at this time.
0 commit comments