From cd9aca123caf1f0fcfc21cb9172d01f18318cf07 Mon Sep 17 00:00:00 2001 From: mbaharip <62494292+mbahArip@users.noreply.github.com> Date: Fri, 24 Jan 2025 17:43:17 +0700 Subject: [PATCH] update: force to use key on production --- src/app/api/internal/encrypt/route.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/api/internal/encrypt/route.ts b/src/app/api/internal/encrypt/route.ts index 87cb1b7..897bbec 100644 --- a/src/app/api/internal/encrypt/route.ts +++ b/src/app/api/internal/encrypt/route.ts @@ -11,6 +11,10 @@ export async function GET(request: NextRequest) { const key = sp.get("key"); if (!query) return new NextResponse("Add query parameter 'q' with the value to encrypt", { status: 400 }); + if (process.env.NODE_ENV !== "development" && !key) { + throw new Error("Key is required in production environment"); + } + const encrypted = await encryptionService.encrypt(query, key ?? undefined); const decrypted = await encryptionService.decrypt(encrypted, key ?? undefined);