chore: Internal request filtering
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import fetch from "fetch-with-proxy";
|
||||
import { useAgent } from "request-filtering-agent";
|
||||
import { Op } from "sequelize";
|
||||
import WebhookDisabledEmail from "@server/emails/templates/WebhookDisabledEmail";
|
||||
import env from "@server/env";
|
||||
@@ -535,6 +536,8 @@ export default class DeliverWebhookTask extends BaseTask<Props> {
|
||||
method: "POST",
|
||||
headers: requestHeaders,
|
||||
body: JSON.stringify(requestBody),
|
||||
redirect: "error",
|
||||
agent: useAgent(subscription.url),
|
||||
});
|
||||
status = response.ok ? "success" : "failed";
|
||||
} catch (err) {
|
||||
|
||||
4
server/typings/fetch-with-proxy.d.ts
vendored
4
server/typings/fetch-with-proxy.d.ts
vendored
@@ -1,3 +1,5 @@
|
||||
declare module "fetch-with-proxy" {
|
||||
export = fetch;
|
||||
import nodeFetch from "node-fetch";
|
||||
|
||||
export = nodeFetch;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,6 @@ export class StateStore {
|
||||
export async function request(endpoint: string, accessToken: string) {
|
||||
const response = await fetch(endpoint, {
|
||||
method: "GET",
|
||||
credentials: "same-origin",
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
|
||||
@@ -3,6 +3,7 @@ import util from "util";
|
||||
import AWS from "aws-sdk";
|
||||
import { addHours, format } from "date-fns";
|
||||
import fetch from "fetch-with-proxy";
|
||||
import { useAgent } from "request-filtering-agent";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import env from "@server/env";
|
||||
import Logger from "@server/logging/Logger";
|
||||
@@ -185,8 +186,9 @@ export const uploadToS3FromUrl = async (
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch(url);
|
||||
// @ts-expect-error buffer exists, need updated typings
|
||||
const res = await fetch(url, {
|
||||
agent: useAgent(url),
|
||||
});
|
||||
const buffer = await res.buffer();
|
||||
await s3
|
||||
.putObject({
|
||||
|
||||
Reference in New Issue
Block a user