diff options
| author | Mohamed Bassem <me@mbassem.com> | 2025-09-07 20:19:52 +0000 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2025-09-07 20:19:52 +0000 |
| commit | 20f4e4712f332a05030a0f248a2caa8d91ec2a36 (patch) | |
| tree | 6926b288b49b519fdcbbfff4bf41ac9cdf9d058a /packages/trpc/routers/apiKeys.ts | |
| parent | e5dea9568b9bb8b267cf89f2c30fa578edef6a3e (diff) | |
| download | karakeep-20f4e4712f332a05030a0f248a2caa8d91ec2a36.tar.zst | |
fix: fix 5xx on invalid api key
Diffstat (limited to 'packages/trpc/routers/apiKeys.ts')
| -rw-r--r-- | packages/trpc/routers/apiKeys.ts | 6 |
1 files changed, 5 insertions, 1 deletions
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, }; |
