fix(firebase-auth): throw HTTPException instead of reponse null (#191)

* fix(firebase-auth): throw HTTPException instead of reponse null

* added changeset
pull/193/head
Kei Kamikawa 2023-10-05 22:42:21 +09:00 committed by GitHub
parent b77369e6f1
commit 794f03c363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/firebase-auth': patch
---
fixed to make HTTPException instead of reponse null

View File

@ -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()
}