mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
feat(config): ✨ Add support for HTTP proxies on outgoing requests
This commit is contained in:
parent
0ecb65de29
commit
b8b822e553
13 changed files with 225 additions and 136 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import type { ServerMetadata } from "@lysand-org/federation/types";
|
||||
import { db } from "~/drizzle/db";
|
||||
import { Instances } from "~/drizzle/schema";
|
||||
import { config } from "~/packages/config-manager";
|
||||
|
||||
/**
|
||||
* Represents an instance in the database.
|
||||
|
|
@ -24,9 +25,9 @@ export const addInstanceIfNotExists = async (url: string) => {
|
|||
}
|
||||
|
||||
// Fetch the instance configuration
|
||||
const metadata = (await fetch(new URL("/.well-known/lysand", origin)).then(
|
||||
(res) => res.json(),
|
||||
)) as ServerMetadata;
|
||||
const metadata = (await fetch(new URL("/.well-known/lysand", origin), {
|
||||
proxy: config.http.proxy.address,
|
||||
}).then((res) => res.json())) as ServerMetadata;
|
||||
|
||||
if (metadata.type !== "ServerMetadata") {
|
||||
throw new Error("Invalid instance metadata (wrong type)");
|
||||
|
|
|
|||
|
|
@ -448,7 +448,9 @@ export const federateNote = async (note: Note) => {
|
|||
);
|
||||
|
||||
// Send request
|
||||
const response = await fetch(request);
|
||||
const response = await fetch(request, {
|
||||
proxy: config.http.proxy.address,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
dualLogger.log(
|
||||
|
|
|
|||
|
|
@ -175,7 +175,9 @@ export const followRequestUser = async (
|
|||
);
|
||||
|
||||
// Send request
|
||||
const response = await fetch(request);
|
||||
const response = await fetch(request, {
|
||||
proxy: config.http.proxy.address,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
dualLogger.log(
|
||||
|
|
@ -230,7 +232,9 @@ export const sendFollowAccept = async (follower: User, followee: User) => {
|
|||
);
|
||||
|
||||
// Send request
|
||||
const response = await fetch(request);
|
||||
const response = await fetch(request, {
|
||||
proxy: config.http.proxy.address,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
dualLogger.log(
|
||||
|
|
@ -258,7 +262,9 @@ export const sendFollowReject = async (follower: User, followee: User) => {
|
|||
);
|
||||
|
||||
// Send request
|
||||
const response = await fetch(request);
|
||||
const response = await fetch(request, {
|
||||
proxy: config.http.proxy.address,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
dualLogger.log(
|
||||
|
|
@ -375,6 +381,7 @@ export const resolveWebFinger = async (
|
|||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
proxy: config.http.proxy.address,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue