repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
The Living OS cockpit
stars
latest
clone command
git clone gitlawb://did:key:z6Mku78K...XywC/living-os-cockp...git clone gitlawb://did:key:z6Mku78K.../living-os-cockp...59751530feat: surface worker supervisor health in live work8h ago| #1 | import { NextRequest, NextResponse } from 'next/server'; |
| #2 | import { AuthMismatchError, getUserContext, publicContext } from '@/lib/user-context'; |
| #3 | |
| #4 | export async function GET(req: NextRequest) { |
| #5 | try { |
| #6 | const ctx = await getUserContext(); |
| #7 | return NextResponse.json(publicContext(ctx)); |
| #8 | } catch (error: any) { |
| #9 | const status = error instanceof AuthMismatchError || error?.status === 403 ? 403 : 401; |
| #10 | const proto = req.headers.get('x-forwarded-proto') ?? 'https'; |
| #11 | const host = req.headers.get('x-forwarded-host') ?? req.headers.get('host') ?? 'theliving.ai'; |
| #12 | const origin = `${proto}://${host}`; |
| #13 | const loginUrl = `https://theliving.ai/auth/login?redirect=${encodeURIComponent(origin)}`; |
| #14 | return NextResponse.json({ |
| #15 | error: status === 403 ? 'identity_mismatch' : 'authentication_required', |
| #16 | detail: error?.message ?? 'Authentication required', |
| #17 | loginUrl, |
| #18 | }, { status }); |
| #19 | } |
| #20 | } |
| #21 |