Add built-in proxy settings for Electron and Gateway (#239)

Co-authored-by: zuolingxuan <zuolingxuan@bytedance.com>
This commit is contained in:
Lingxuan Zuo
2026-03-02 17:33:06 +08:00
committed by GitHub
Unverified
parent c09b45832b
commit e40f4b2163
20 changed files with 758 additions and 25 deletions

View File

@@ -0,0 +1,21 @@
/**
* Use Electron's network stack when available so requests honor
* session.defaultSession.setProxy(...). Fall back to the Node global fetch
* for non-Electron test environments.
*/
export async function proxyAwareFetch(
input: string | URL,
init?: RequestInit
): Promise<Response> {
if (process.versions.electron) {
try {
const { net } = await import('electron');
return await net.fetch(input, init);
} catch {
// Fall through to the global fetch.
}
}
return await fetch(input, init);
}