fix: return clear error when social auth provider is not configured

This commit is contained in:
Rotimi Best
2026-06-14 09:56:30 +01:00
parent 64571dd5ec
commit ee4d4922d6
13 changed files with 41 additions and 14 deletions
+16
View File
@@ -7,6 +7,7 @@ import { randomBytes } from 'crypto';
import { API_SERVER_URL } from '@api/constants';
import { Hono } from '@api/utils/hono';
import { ErrorCodes } from '@api/utils/errors';
import { accountRouter } from '@api/routes/account';
import { agentRouter } from '@api/routes/agent';
import { auth } from '@cio/db/auth';
@@ -141,6 +142,21 @@ export const app = new Hono()
}
}
// Check if the social auth provider is configured before forwarding
// to Better Auth, which returns a confusing generic 500 otherwise.
if (c.req.method === 'POST' && c.req.path === '/api/auth/sign-in/social') {
if (!process.env.GOOGLE_CLIENT_ID || !process.env.GOOGLE_CLIENT_SECRET) {
return c.json(
{
success: false,
error: "This auth provider isn't enabled.",
code: ErrorCodes.SOCIAL_AUTH_NOT_ENABLED
},
400
);
}
}
const response = await auth.handler(request);
// Outbound: if the OAuth callback redirected to