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.
This commit is contained in:
@@ -2,41 +2,6 @@ import { NextResponse } from 'next/server';
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
export function middleware(request: NextRequest) {
|
||||
// Protect admin routes with Basic Auth (legacy routes)
|
||||
if (request.nextUrl.pathname.startsWith('/admin') ||
|
||||
request.nextUrl.pathname.startsWith('/dashboard') ||
|
||||
request.nextUrl.pathname.startsWith('/control')) {
|
||||
|
||||
const authHeader = request.headers.get('authorization');
|
||||
const basicAuth = process.env.ADMIN_BASIC_AUTH;
|
||||
|
||||
if (!basicAuth) {
|
||||
return new NextResponse('Admin access not configured', { status: 500 });
|
||||
}
|
||||
|
||||
if (!authHeader || !authHeader.startsWith('Basic ')) {
|
||||
return new NextResponse('Authentication required', {
|
||||
status: 401,
|
||||
headers: {
|
||||
'WWW-Authenticate': 'Basic realm="Admin Area"',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const credentials = authHeader.split(' ')[1];
|
||||
const [username, password] = Buffer.from(credentials, 'base64').toString().split(':');
|
||||
const [expectedUsername, expectedPassword] = basicAuth.split(':');
|
||||
|
||||
if (username !== expectedUsername || password !== expectedPassword) {
|
||||
return new NextResponse('Invalid credentials', {
|
||||
status: 401,
|
||||
headers: {
|
||||
'WWW-Authenticate': 'Basic realm="Admin Area"',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 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') ||
|
||||
|
||||
Reference in New Issue
Block a user