initial commit

This commit is contained in:
shafin-r
2025-07-03 01:43:25 +06:00
commit 5dc53b896e
279 changed files with 28956 additions and 0 deletions

22
torpedo/middleware.ts Normal file
View File

@ -0,0 +1,22 @@
import { NextResponse } from 'next/server';
import { getToken } from 'next-auth/jwt';
import type { NextRequest } from 'next/server';
export async function middleware(req: NextRequest) {
// Get the token from the request
const token = await getToken({ req, secret: process.env.NEXTAUTH_SECRET });
const { pathname } = req.nextUrl;
// If the user is not authenticated and trying to access the dashboard, redirect to login
if (!token && pathname.startsWith('/dashboard')) {
return NextResponse.redirect(new URL('/auth/login', req.url));
}
// Allow the request to proceed
return NextResponse.next();
}
export const config = {
matcher: ['/dashboard/:path*'], // Protect all routes under /dashboard
};