Skip to content

Commit 7d23e23

Browse files
committed
remove random error code
1 parent fc1ca1e commit 7d23e23

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

apps/sim/app/api/auth/socket-token/route.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,22 @@ import { auth } from '@/lib/auth'
44
import { isAuthDisabled } from '@/lib/core/config/feature-flags'
55

66
export async function POST() {
7-
try {
8-
if (isAuthDisabled) {
9-
return NextResponse.json({ token: 'anonymous-socket-token' })
10-
}
7+
if (isAuthDisabled) {
8+
return NextResponse.json({ token: 'anonymous-socket-token' })
9+
}
1110

11+
try {
1212
const hdrs = await headers()
1313
const response = await auth.api.generateOneTimeToken({
1414
headers: hdrs,
1515
})
1616

1717
if (!response?.token) {
18-
// No token usually means invalid/expired session
1918
return NextResponse.json({ error: 'Authentication required' }, { status: 401 })
2019
}
2120

2221
return NextResponse.json({ token: response.token })
23-
} catch (error) {
24-
// Check if it's an auth-related error
25-
const errorMessage = error instanceof Error ? error.message : String(error)
26-
if (
27-
errorMessage.includes('session') ||
28-
errorMessage.includes('unauthorized') ||
29-
errorMessage.includes('unauthenticated')
30-
) {
31-
return NextResponse.json({ error: 'Authentication required' }, { status: 401 })
32-
}
33-
return NextResponse.json({ error: 'Failed to generate token' }, { status: 500 })
22+
} catch {
23+
return NextResponse.json({ error: 'Authentication required' }, { status: 401 })
3424
}
3525
}

apps/sim/app/workspace/providers/socket-provider.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ export function SocketProvider({ children, user }: SocketProviderProps) {
155155
headers: { 'cache-control': 'no-store' },
156156
})
157157
if (!res.ok) {
158-
// 401/403 indicates session expiry - don't keep retrying
159-
if (res.status === 401 || res.status === 403) {
158+
if (res.status === 401) {
160159
throw new Error('Authentication required')
161160
}
162161
throw new Error('Failed to generate socket token')

0 commit comments

Comments
 (0)