Initial ui

This commit is contained in:
Jack Mechem 2026-03-25 23:33:09 -07:00
parent 526822335e
commit 4bfb87448f
18 changed files with 702 additions and 92 deletions

32
middleware.ts Normal file
View file

@ -0,0 +1,32 @@
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function middleware(req: NextRequest) {
const authHeader = req.headers.get('authorization');
// Change these to your desired username and password
const USERNAME = process.env.DASHBOARD_USER;
const PASSWORD = process.env.DASHBOARD_PASS;
if (authHeader) {
const auth = authHeader.split(' ')[1];
const [user, pwd] = Buffer.from(auth, 'base64').toString().split(':');
if (user === USERNAME && pwd === PASSWORD) {
return NextResponse.next();
}
}
// If not authenticated, trigger the browser's native login popup
return new NextResponse('Authentication required', {
status: 401,
headers: {
'WWW-Authenticate': 'Basic realm="Secure Area"',
},
});
}
// Only protect the dashboard, not the static assets
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
};