busi488budgetbuddy/middleware.ts
Joey Eamigh c88d4ba1a8
Customize myAI3 as BudgetBuddy personal finance assistant
- Configure identity, prompts, guardrails for personal finance domain
- Add 6 knowledge sources to Pinecone RAG (budgeting, investing, credit, etc.)
- Add password protection via Next.js middleware
- Add Dockerfile for container deployment
- Customize terms of use with financial disclaimers
2026-04-05 12:14:59 -04:00

28 lines
721 B
TypeScript

import { NextRequest, NextResponse } from "next/server";
export function middleware(request: NextRequest) {
const authHeader = request.headers.get("authorization");
if (authHeader) {
const [scheme, encoded] = authHeader.split(" ");
if (scheme === "Basic" && encoded) {
const decoded = atob(encoded);
const [, password] = decoded.split(":");
if (password === process.env.AUTH_PASSWORD) {
return NextResponse.next();
}
}
}
return new NextResponse("Authentication required", {
status: 401,
headers: {
"WWW-Authenticate": 'Basic realm="BudgetBuddy"',
},
});
}
export const config = {
matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
};