diff --git a/packages/adapters/hono/src/index.ts b/packages/adapters/hono/src/index.ts index f5b3cef7d..1a904c024 100644 --- a/packages/adapters/hono/src/index.ts +++ b/packages/adapters/hono/src/index.ts @@ -259,6 +259,28 @@ export function createHonoApp(options: ObjectStackHonoOptions): Hono { authService = null; } + // Handle /auth/config endpoint specifically (not handled by better-auth) + if (path === 'config' && method === 'GET' && authService) { + try { + const config = (authService as any).getPublicConfig?.(); + if (config) { + return c.json({ + success: true, + data: config, + }); + } + } catch (error) { + const err = error instanceof Error ? error : new Error(String(error)); + return c.json({ + success: false, + error: { + code: 'auth_config_error', + message: err.message, + }, + }, 500); + } + } + if (authService && typeof authService.handleRequest === 'function') { const response = await authService.handleRequest(c.req.raw); return new Response(response.body, { diff --git a/packages/plugins/plugin-auth/src/auth-manager.test.ts b/packages/plugins/plugin-auth/src/auth-manager.test.ts index 0eef726b6..f4d010c28 100644 --- a/packages/plugins/plugin-auth/src/auth-manager.test.ts +++ b/packages/plugins/plugin-auth/src/auth-manager.test.ts @@ -815,11 +815,13 @@ describe('AuthManager', () => { id: 'google', name: 'Google', enabled: true, + type: 'social', }); expect(config.socialProviders[1]).toEqual({ id: 'github', name: 'GitHub', enabled: true, + type: 'social', }); // Should NOT include sensitive data @@ -899,6 +901,7 @@ describe('AuthManager', () => { id: 'customProvider', name: 'CustomProvider', enabled: true, + type: 'social', }); }); }); diff --git a/packages/plugins/plugin-auth/src/auth-plugin.ts b/packages/plugins/plugin-auth/src/auth-plugin.ts index e74477b69..8abc6ef57 100644 --- a/packages/plugins/plugin-auth/src/auth-plugin.ts +++ b/packages/plugins/plugin-auth/src/auth-plugin.ts @@ -246,27 +246,11 @@ export class AuthPlugin implements Plugin { const rawApp = (httpServer as any).getRawApp(); - // Register auth config endpoint - public endpoint for frontend discovery - rawApp.get(`${basePath}/config`, async (c: any) => { - try { - const config = this.authManager!.getPublicConfig(); - return c.json({ - success: true, - data: config, - }); - } catch (error) { - const err = error instanceof Error ? error : new Error(String(error)); - ctx.logger.error('Auth config error:', err); - - return c.json({ - success: false, - error: { - code: 'auth_config_error', - message: err.message, - }, - }, 500); - } - }); + // NOTE: The `/config` endpoint is now handled in the Hono adapter itself + // (packages/adapters/hono/src/index.ts) to avoid route ordering conflicts. + // The adapter's catch-all `/auth/*` route intercepts all auth requests + // before plugin routes can be registered, so we check for `/config` there + // and call getPublicConfig() directly on the auth service. // Register wildcard route to forward all auth requests to better-auth. // better-auth is configured with basePath matching our route prefix, so we