chore: Secure routes with auth middleware, update text and fix minor bugs

This commit is contained in:
2026-08-03 17:55:20 +05:30
parent 62d15c85f6
commit c2fab50749
68 changed files with 2515 additions and 6808 deletions

27
src/proxy.ts Normal file
View File

@@ -0,0 +1,27 @@
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function proxy(request: NextRequest) {
const token = request.cookies.get('auth_token')?.value;
const path = request.nextUrl.pathname;
// Protect /admin routes
if (path.startsWith('/admin')) {
if (token !== 'admin') {
return NextResponse.redirect(new URL('/login', request.url));
}
}
// Protect /dashboard routes
if (path.startsWith('/dashboard')) {
if (!token) {
return NextResponse.redirect(new URL('/login', request.url));
}
}
return NextResponse.next();
}
export const config = {
matcher: ['/dashboard/:path*', '/admin/:path*']
};