Skip to content

Commit d01608a

Browse files
authored
Update proxy-config.ts (#138)
1 parent fdf4d59 commit d01608a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

proxy-config.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)