From 4bb16d287b84708ea4026c4468748d1f59134fb3 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 23 Apr 2024 21:23:18 +0100 Subject: [PATCH] verify paste length on server --- src/app/(pages)/page.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/(pages)/page.tsx b/src/app/(pages)/page.tsx index 936001c..1ac271a 100644 --- a/src/app/(pages)/page.tsx +++ b/src/app/(pages)/page.tsx @@ -18,15 +18,6 @@ export default function Home(): ReactElement { return; } - // Limit the paste size to 400,000 characters - if (value.length > 400_000) { - toast({ - title: "Paste", - description: "Pastes can't be longer than 400,000 characters", - }); - return; - } - // Upload the paste to the server const response = await fetch( `${process.env.NEXT_PUBLIC_API_ENDPOINT}/upload`, @@ -39,8 +30,17 @@ export default function Home(): ReactElement { }, ); - // Redirect to the new paste const data = await response.json(); + + if (!response.ok) { + toast({ + title: "Paste", + description: data.message, + }); + return; + } + + // Redirect to the new paste window.location.href = `/${data.id}`; }