web_next/scheduler_app/middleware.ts

16 lines
No EOL
569 B
TypeScript

import {getKindeServerSession} from "@kinde-oss/kinde-auth-nextjs/server";
import { NextResponse } from 'next/server'
// This function can be marked `async` if using `await` inside
export async function middleware(request) {
const {isAuthenticated} = getKindeServerSession();
if(!(await isAuthenticated())){
return NextResponse.redirect(new URL('/api/auth/login?post_login_redirect_url=/dashboard', request.url))
}
}
// See "Matching Paths" below to learn more
export const config = {
matcher: ['/dashboard/:path*', '/create_business'],
}