Files
chorus-services/modules/dashboard/middleware.ts
tony 2e1bb2e55e Major update to chorus.services platform
- Extensive updates to system configuration and deployment
- Enhanced documentation and architecture improvements
- Updated dependencies and build configurations
- Improved service integrations and workflows

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-17 22:01:07 +10:00

37 lines
1.1 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server'
export function middleware(request: NextRequest) {
// Simple basic auth for dashboard protection
const authHeader = request.headers.get('authorization')
if (!authHeader) {
return new NextResponse(null, {
status: 401,
headers: {
'WWW-Authenticate': 'Basic realm="CHORUS Dashboard"',
},
})
}
const credentials = authHeader.split(' ')[1]
const [username, password] = Buffer.from(credentials, 'base64').toString().split(':')
// Simple hardcoded credentials - in production, use environment variables
const validUsername = process.env.DASHBOARD_USERNAME || 'chorus'
const validPassword = process.env.DASHBOARD_PASSWORD || 'services2025!'
if (username !== validUsername || password !== validPassword) {
return new NextResponse(null, {
status: 401,
headers: {
'WWW-Authenticate': 'Basic realm="CHORUS Dashboard"',
},
})
}
return NextResponse.next()
}
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
}