From 794f03c3633abefce1b16fb1f4322d87f2568a8e Mon Sep 17 00:00:00 2001 From: Kei Kamikawa Date: Thu, 5 Oct 2023 22:42:21 +0900 Subject: [PATCH] fix(firebase-auth): throw HTTPException instead of reponse null (#191) * fix(firebase-auth): throw HTTPException instead of reponse null * added changeset --- .changeset/make-http-exception.md | 5 +++++ packages/firebase-auth/src/index.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/make-http-exception.md diff --git a/.changeset/make-http-exception.md b/.changeset/make-http-exception.md new file mode 100644 index 00000000..f3ae9fdd --- /dev/null +++ b/.changeset/make-http-exception.md @@ -0,0 +1,5 @@ +--- +'@hono/firebase-auth': patch +--- + +fixed to make HTTPException instead of reponse null \ No newline at end of file diff --git a/packages/firebase-auth/src/index.ts b/packages/firebase-auth/src/index.ts index b0dc335e..c4b56503 100644 --- a/packages/firebase-auth/src/index.ts +++ b/packages/firebase-auth/src/index.ts @@ -1,6 +1,7 @@ import type { KeyStorer, FirebaseIdToken } from 'firebase-auth-cloudflare-workers' import { Auth, WorkersKVStoreSingle } from 'firebase-auth-cloudflare-workers' import type { Context, MiddlewareHandler } from 'hono' +import { HTTPException } from 'hono/http-exception' export type VerifyFirebaseAuthEnv = { PUBLIC_JWK_CACHE_KEY?: string | undefined @@ -61,9 +62,11 @@ export const verifyFirebaseAuth = (userConfig: VerifyFirebaseAuthConfig): Middle err, }) } - return new Response(null, { + + const res = new Response('Unauthorized', { status: 401, }) + throw new HTTPException(401, { res }) } await next() }