diff --git a/.gitignore b/.gitignore index 8e0a7e6..8cdcd15 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/SharpbinV3.Client/src/routes/raw/[id]/+server.ts b/SharpbinV3.Client/src/routes/raw/[id]/+server.ts new file mode 100644 index 0000000..bd4ec2b --- /dev/null +++ b/SharpbinV3.Client/src/routes/raw/[id]/+server.ts @@ -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' + } + }); +};