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);
}
@@ -1094,7 +1094,7 @@
class={data.paste.syntax === 'markdown'
? 'markdown rounded-b-md bg-neutral-800 p-4'
: data.paste.syntax === 'csv'
? 'csv-container scrollbar overflow-x-auto overflow-y-auto scrollbar-thumb-neutral-600 scrollbar-track-neutral-800'
? 'csv-container scrollbar scrollbar-thumb-neutral-600 scrollbar-track-neutral-800 overflow-x-auto overflow-y-auto'
: 'codeblock-with-lines overflow-x-auto overflow-y-auto'}
class:hidden={!contentRendered}
onclick={handleMarkdownClick}
@@ -0,0 +1,13 @@
import { proxyBackendRequest } from '$lib/server/proxy';
import type { RequestHandler } from './$types';
const handle: RequestHandler = ({ params, request, url }) => {
return proxyBackendRequest('/api', params.path, request, url);
};
export const GET = handle;
export const POST = handle;
export const PUT = handle;
export const PATCH = handle;
export const DELETE = handle;
export const OPTIONS = handle;
@@ -0,0 +1,6 @@
import { proxyBackendRequest } from '$lib/server/proxy';
import type { RequestHandler } from './$types';
export const GET: RequestHandler = ({ request, url }) => {
return proxyBackendRequest('/openapi', '', request, url);
};
@@ -0,0 +1,6 @@
import { proxyBackendRequest } from '$lib/server/proxy';
import type { RequestHandler } from './$types';
export const GET: RequestHandler = ({ params, request, url }) => {
return proxyBackendRequest('/openapi', params.path, request, url);
};