fix: multiple vulnerabilities

This commit is contained in:
2026-06-17 21:43:41 -04:00
parent 6c810b07b7
commit 6a7b8653dc
15 changed files with 83 additions and 27 deletions
+28
View File
@@ -0,0 +1,28 @@
import { apiUrl } from '$lib/server/api';
const methodsWithoutBody = new Set(['GET', 'HEAD']);
export async function proxyBackendRequest(
prefix: string,
path: string,
request: Request,
url: URL
) {
const targetUrl = new URL(`${prefix}/${path}`.replace(/\/+$/, ''), apiUrl);
targetUrl.search = url.search;
const headers = new Headers(request.headers);
headers.delete('host');
const init: RequestInit = {
method: request.method,
headers,
redirect: 'manual'
};
if (!methodsWithoutBody.has(request.method)) {
init.body = await request.arrayBuffer();
}
return fetch(targetUrl, init);
}