From 6b4932b4c504feeeb422879495bc9674e5b3ead1 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Thu, 30 Oct 2025 19:26:19 +0100 Subject: [PATCH] Add error handling --- backend/api/src/auth-google.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/api/src/auth-google.ts b/backend/api/src/auth-google.ts index d22754e9..36063fa2 100644 --- a/backend/api/src/auth-google.ts +++ b/backend/api/src/auth-google.ts @@ -1,4 +1,4 @@ -import {APIHandler} from './helpers/endpoint' +import {APIError, APIHandler} from './helpers/endpoint' import {GOOGLE_CLIENT_ID} from "common/constants"; export const authGoogle: APIHandler<'auth-google'> = async ( @@ -14,7 +14,7 @@ export const authGoogle: APIHandler<'auth-google'> = async ( code: code as string, code_verifier: codeVerifier as string, grant_type: 'authorization_code', - redirect_uri: 'https://www.compassmeet.com/auth/callback', + redirect_uri: `https://compassmeet.com/auth/callback`, }; console.log('Body:', body) const tokenRes = await fetch('https://oauth2.googleapis.com/token', { @@ -24,6 +24,10 @@ export const authGoogle: APIHandler<'auth-google'> = async ( }); const tokens = await tokenRes.json(); + if (tokens.error) { + console.error('Google token error:', tokens); + throw new APIError(400, 'Google token error: ' + JSON.stringify(tokens)) + } console.log('Google Tokens:', tokens); return {