Files
zeekay bb7d188529 feat(dashboard): landing page with login + docs hub
- Replace redirect-to-dashboard with proper landing page showing
  branding, feature cards, chain chips, and sign-in button
- Add /docs hub page with section cards, API reference, and examples
- Update middleware to allow / and /docs as public paths
2025-12-27 14:31:06 -08:00

39 lines
1001 B
TypeScript

import { NextResponse, type NextRequest } from 'next/server'
// Public paths — accessible without authentication
const PUBLIC_PATHS = [
'/login',
'/auth/callback',
'/api',
'/healthz',
'/docs',
]
export function middleware(request: NextRequest) {
const { pathname } = request.nextUrl
// Landing page is always public
if (pathname === '/') {
return NextResponse.next()
}
// Allow public paths without auth check
if (PUBLIC_PATHS.some((p) => pathname === p || pathname.startsWith(p + '/'))) {
return NextResponse.next()
}
// Check for session cookie set by auth.ts setTokens()
const session = request.cookies.get('lux_mpc_session')
if (!session?.value) {
const loginUrl = new URL('/login', request.url)
loginUrl.searchParams.set('from', pathname)
return NextResponse.redirect(loginUrl)
}
return NextResponse.next()
}
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)'],
}