mirror of
https://github.com/luxfi/mpc.git
synced 2026-09-24 00:26:24 +00:00
- 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
39 lines
1001 B
TypeScript
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)$).*)'],
|
|
}
|