Initial commit - QR Master application
This commit is contained in:
52
src/middleware.ts
Normal file
52
src/middleware.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { withAuth } from 'next-auth/middleware';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export default withAuth(
|
||||
function middleware(req) {
|
||||
return NextResponse.next();
|
||||
},
|
||||
{
|
||||
callbacks: {
|
||||
authorized: ({ req, token }) => {
|
||||
// Public routes that don't require authentication
|
||||
const publicPaths = [
|
||||
'/',
|
||||
'/pricing',
|
||||
'/faq',
|
||||
'/blog',
|
||||
'/login',
|
||||
'/signup',
|
||||
'/api/auth',
|
||||
];
|
||||
|
||||
const path = req.nextUrl.pathname;
|
||||
|
||||
// Allow public paths
|
||||
if (publicPaths.some(p => path.startsWith(p))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Allow redirect routes
|
||||
if (path.startsWith('/r/')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Require authentication for all other routes
|
||||
return !!token;
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export const config = {
|
||||
matcher: [
|
||||
/*
|
||||
* Match all request paths except for the ones starting with:
|
||||
* - _next/static (static files)
|
||||
* - _next/image (image optimization files)
|
||||
* - favicon.ico (favicon file)
|
||||
* - public folder
|
||||
*/
|
||||
'/((?!_next/static|_next/image|favicon.ico|logo.svg|og-image.png).*)',
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user