File tree Expand file tree Collapse file tree
packages/plugins/plugin-auth/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,13 +122,17 @@ export class AuthPlugin implements Plugin {
122122 const basePath = this . options . basePath || '/api/v1/auth' ;
123123
124124 // Get raw Hono app to use native wildcard routing
125- const rawApp = ( httpServer as any ) . getRawApp ?.( ) ;
126-
127- if ( ! rawApp ) {
128- ctx . logger . error ( 'Cannot access raw HTTP server app - wildcard routing not supported' ) ;
129- throw new Error ( 'HTTP server does not support wildcard routing' ) ;
125+ // Type assertion is safe here because we explicitly require Hono server as a dependency
126+ if ( ! ( 'getRawApp' in httpServer ) || typeof ( httpServer as any ) . getRawApp !== 'function' ) {
127+ ctx . logger . error ( 'HTTP server does not support getRawApp() - wildcard routing requires Hono server' ) ;
128+ throw new Error (
129+ 'AuthPlugin requires HonoServerPlugin for wildcard routing support. ' +
130+ 'Please ensure HonoServerPlugin is loaded before AuthPlugin.'
131+ ) ;
130132 }
131133
134+ const rawApp = ( httpServer as any ) . getRawApp ( ) ;
135+
132136 // Register wildcard route to forward all auth requests to better-auth
133137 // Better-auth expects requests at its baseURL, so we need to preserve the full path
134138 rawApp . all ( `${ basePath } /*` , async ( c : any ) => {
You can’t perform that action at this time.
0 commit comments