feat: /raw/{id} endpoint

This commit is contained in:
2026-01-18 22:00:54 -05:00
parent c08fe0690f
commit ca87b1a5f2
2 changed files with 19 additions and 4 deletions
-4
View File
@@ -33,10 +33,6 @@ bld/
[Ll]og/
[Ll]ogs/
p/
privp/
raw/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
@@ -0,0 +1,19 @@
import type { RequestHandler } from '@sveltejs/kit';
const apiUrl = process.env.VITE_API_URL || 'http://localhost:5050';
export const GET: RequestHandler = async ({ params }) => {
const { id } = params;
const res = await fetch(`${apiUrl}/api/paste/${id}/raw`);
if (res.status === 404) {
return new Response('Paste not found', { status: 404 });
}
const content = await res.text();
return new Response(content, {
headers: {
'Content-Type': 'text/plain; charset=utf-8'
}
});
};