feat(config): Add support for HTTP proxies on outgoing requests

This commit is contained in:
Jesse Wierzbinski 2024-06-25 17:13:40 -10:00
parent 0ecb65de29
commit b8b822e553
No known key found for this signature in database
13 changed files with 225 additions and 136 deletions

View file

@ -1,5 +1,6 @@
import type { ContentFormat } from "@lysand-org/federation/types";
import { lookup } from "mime-types";
import { config } from "~/packages/config-manager";
export const getBestContentType = (content?: ContentFormat) => {
if (!content) {
@ -51,9 +52,10 @@ export const mimeLookup = async (url: string) => {
return naiveLookup;
}
const fetchLookup = fetch(url, { method: "HEAD" }).then(
(response) => response.headers.get("content-type") || "",
);
const fetchLookup = fetch(url, {
method: "HEAD",
proxy: config.http.proxy.address,
}).then((response) => response.headers.get("content-type") || "");
return fetchLookup;
};