Skip to content

Commit 20f4e47

Browse files
committed
fix: fix 5xx on invalid api key
1 parent e5dea95 commit 20f4e47

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/trpc/routers/apiKeys.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ export const apiKeysAppRouter = router({
112112
.input(z.object({ apiKey: z.string() }))
113113
.output(z.object({ success: z.boolean() }))
114114
.mutation(async ({ input, ctx }) => {
115-
await authenticateApiKey(input.apiKey, ctx.db); // Throws if the key is invalid
115+
try {
116+
await authenticateApiKey(input.apiKey, ctx.db); // Throws if the key is invalid
117+
} catch {
118+
throw new TRPCError({ code: "UNAUTHORIZED" });
119+
}
116120
return {
117121
success: true,
118122
};

0 commit comments

Comments
 (0)