fix(auth): log real Firebase error + add NUXT_FIREBASE_API_KEY to docker-compose
This commit is contained in:
@@ -23,10 +23,19 @@ export default defineEventHandler(async (event) => {
|
||||
throw createError({ statusCode: 500, message: 'Firebase API key not configured' })
|
||||
}
|
||||
|
||||
const verifyRes = await $fetch<any>(
|
||||
`https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=${apiKey}`,
|
||||
{ method: 'POST', body: { idToken } }
|
||||
).catch(() => null)
|
||||
console.log('[Auth] Received idToken, length:', idToken?.length || 0)
|
||||
console.log('[Auth] Using API key (masked):', apiKey ? `${apiKey.slice(0, 6)}...${apiKey.slice(-4)}` : 'EMPTY')
|
||||
|
||||
let verifyRes: any
|
||||
try {
|
||||
verifyRes = await $fetch<any>(
|
||||
`https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=${apiKey}`,
|
||||
{ method: 'POST', body: { idToken } }
|
||||
)
|
||||
} catch (err: any) {
|
||||
console.error('[Auth] Firebase token verification failed:', err?.data || err?.message || err)
|
||||
throw createError({ statusCode: 401, message: 'Invalid Firebase token' })
|
||||
}
|
||||
|
||||
if (!verifyRes?.users?.[0]) {
|
||||
throw createError({ statusCode: 401, message: 'Invalid Firebase token' })
|
||||
|
||||
Reference in New Issue
Block a user