feat: rebuild xiteng.site homelab platform

This commit is contained in:
2026-08-12 09:48:25 +08:00
parent 557b0eca33
commit 5b84988789
128 changed files with 14979 additions and 292 deletions
+16
View File
@@ -0,0 +1,16 @@
import nodeFetch from "node-fetch";
import {ProxyAgent} from "proxy-agent";
import type {ProviderDefinition, ProviderSecret} from "./provider-types";
export function createServerProviderFetch(provider: ProviderDefinition, secret: ProviderSecret) {
const proxy = provider.connection.proxy;
if (!proxy) return fetch;
const proxyUrl = new URL(proxy.url);
if (secret.proxy?.username) proxyUrl.username = secret.proxy.username;
if (secret.proxy?.password) proxyUrl.password = secret.proxy.password;
const agent = new ProxyAgent({getProxyForUrl: () => proxyUrl.toString()});
return async (input: RequestInfo | URL, init?: RequestInit) => {
const response = await nodeFetch(String(input), {...init, agent} as never);
return response as unknown as Response;
};
}