Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/adapters/hono/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
3 changes: 3 additions & 0 deletions packages/plugins/plugin-auth/src/auth-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -899,6 +901,7 @@ describe('AuthManager', () => {
id: 'customProvider',
name: 'CustomProvider',
enabled: true,
type: 'social',
});
});
});
Expand Down
26 changes: 5 additions & 21 deletions packages/plugins/plugin-auth/src/auth-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading