diff --git a/.gitea/workflows/ci-cd-with-gitea-vars.yml b/.gitea/workflows/ci-cd-with-gitea-vars.yml index 0f8226f..0e105f3 100644 --- a/.gitea/workflows/ci-cd-with-gitea-vars.yml +++ b/.gitea/workflows/ci-cd-with-gitea-vars.yml @@ -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 diff --git a/middleware.ts b/middleware.ts index def905e..b8a66bd 100644 --- a/middleware.ts +++ b/middleware.ts @@ -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') ||