Files
portfolio/middleware.ts
denshooter 1f7547a562
Some checks failed
CI/CD Pipeline (Using Gitea Variables & Secrets) / production (push) Failing after 10m26s
Test Gitea Variables and Secrets / test-variables (push) Successful in 3s
Fix health check timing and improve admin login
- Increase health check wait times in Gitea Actions workflow
- Add additional main page accessibility check with longer timeout
- Remove basic auth middleware to use custom admin login only
- Custom admin login at /manage route provides better UX than browser basic auth

This should resolve the 'Main page is not accessible' issue and provide a nicer admin login experience.
2025-10-15 17:00:06 +02:00

30 lines
1.0 KiB
TypeScript

import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function middleware(request: NextRequest) {
// For /manage and /editor routes, let them handle their own session-based auth
// These routes will redirect to login if not authenticated
if (request.nextUrl.pathname.startsWith('/manage') ||
request.nextUrl.pathname.startsWith('/editor')) {
// Let the page handle authentication via session tokens
return NextResponse.next();
}
// For all other routes, continue with normal processing
return NextResponse.next();
}
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - api/email (email API routes)
* - api/health (health check)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
* - api/auth (auth API routes - need to be processed)
*/
'/((?!api/email|api/health|_next/static|_next/image|favicon.ico|api/auth).*)',
],
};