From 20f4e4712f332a05030a0f248a2caa8d91ec2a36 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 7 Sep 2025 20:19:52 +0000 Subject: fix: fix 5xx on invalid api key --- packages/trpc/routers/apiKeys.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'packages/trpc/routers/apiKeys.ts') diff --git a/packages/trpc/routers/apiKeys.ts b/packages/trpc/routers/apiKeys.ts index b7d11d41..dc3a3527 100644 --- a/packages/trpc/routers/apiKeys.ts +++ b/packages/trpc/routers/apiKeys.ts @@ -112,7 +112,11 @@ export const apiKeysAppRouter = router({ .input(z.object({ apiKey: z.string() })) .output(z.object({ success: z.boolean() })) .mutation(async ({ input, ctx }) => { - await authenticateApiKey(input.apiKey, ctx.db); // Throws if the key is invalid + try { + await authenticateApiKey(input.apiKey, ctx.db); // Throws if the key is invalid + } catch { + throw new TRPCError({ code: "UNAUTHORIZED" }); + } return { success: true, }; -- cgit v1.2.3-70-g09d2