Fix health check timing and improve admin login
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

- 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:
2025-10-15 17:00:06 +02:00
parent 1bc50ea7e5
commit 1f7547a562
2 changed files with 14 additions and 38 deletions

View File

@@ -142,7 +142,7 @@ jobs:
- name: Wait for containers to be ready
run: |
echo "⏳ Waiting for containers to be ready..."
sleep 30
sleep 45
# Check if all containers are running
echo "📊 Checking container status..."
@@ -150,12 +150,23 @@ jobs:
# Wait for application container to be healthy
echo "🏥 Waiting for application container to be healthy..."
for i in {1..30}; do
for i in {1..60}; do
if docker exec portfolio-app curl -f http://localhost:3000/api/health > /dev/null 2>&1; then
echo "✅ Application container is healthy!"
break
fi
echo "⏳ Waiting for application container... ($i/30)"
echo "⏳ Waiting for application container... ($i/60)"
sleep 5
done
# Additional wait for main page to be accessible
echo "🌐 Waiting for main page to be accessible..."
for i in {1..30}; do
if curl -f http://localhost:3000/ > /dev/null 2>&1; then
echo "✅ Main page is accessible!"
break
fi
echo "⏳ Waiting for main page... ($i/30)"
sleep 3
done

View File

@@ -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') ||