File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
apps/sim/app/api/auth/socket-token Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,12 @@ export async function POST() {
2525 } catch ( error ) {
2626 // better-auth's sessionMiddleware throws APIError("UNAUTHORIZED") with no message
2727 // when the session is missing/expired — surface this as a 401, not a 500.
28- const apiError = error as { statusCode ?: number ; status ?: string }
29- if ( apiError . statusCode === 401 || apiError . status === 'UNAUTHORIZED' ) {
28+ if (
29+ error instanceof Error &&
30+ ( 'statusCode' in error || 'status' in error ) &&
31+ ( ( error as Record < string , unknown > ) . statusCode === 401 ||
32+ ( error as Record < string , unknown > ) . status === 'UNAUTHORIZED' )
33+ ) {
3034 logger . warn ( 'Socket token request with invalid/expired session' )
3135 return NextResponse . json ( { error : 'Authentication required' } , { status : 401 } )
3236 }
You can’t perform that action at this time.
0 commit comments