finally building

This commit is contained in:
Om Lanke
2025-07-02 12:05:38 +05:30
parent ba6ee585dc
commit 449629ece2
40 changed files with 2253 additions and 3711 deletions

View File

@@ -1,18 +1,20 @@
import { auth } from '@workspace/auth';
import { NextResponse } from 'next/server';
import { auth } from '@/auth';
import { NextResponse, NextRequest } from 'next/server';
export default auth((req: any) => {
// If the user is unauthenticated or a student, allow the request.
if (!req.auth || req.auth.user?.role === 'USER') {
export default auth((req: NextRequest) => {
if (!req.auth) {
return NextResponse.redirect(new URL('/login', req.url));
}
if (req.auth.user?.role === 'USER') {
return NextResponse.next();
}
// Otherwise, redirect to the admin app.
const adminURL = process.env.ADMIN_URL ?? 'http://localhost:3001';
const adminUrl = process.env.ADMIN_URL ?? 'http://localhost:3001';
return NextResponse.redirect(new URL(adminURL, req.url));
}) as any;
return NextResponse.redirect(new URL(adminUrl, req.url));
});
export const config = {
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
matcher: ['/((?!api|_next/static|_next/image|favicon.ico|login).*)'],
};