- 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
28 lines
721 B
TypeScript
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).*)"],
|
|
};
|