generated from fahricansecer/boilerplate-fe
25 lines
845 B
TypeScript
25 lines
845 B
TypeScript
/**
|
|
* Auth Configuration
|
|
* Controls whether authentication is required for the app
|
|
*/
|
|
|
|
export const authConfig = {
|
|
// If true, users must login to access the app
|
|
// If false, app is public with optional login
|
|
isAuthRequired: process.env.NEXT_PUBLIC_AUTH_REQUIRED === "true",
|
|
|
|
// Public routes that don't require authentication (when auth is required)
|
|
publicRoutes: ["/signin", "/signup", "/forgot-password"],
|
|
|
|
// Routes that should always be protected (even when auth is optional)
|
|
protectedRoutes: ["/admin", "/settings", "/profile"],
|
|
};
|
|
|
|
export const isPublicRoute = (pathname: string): boolean => {
|
|
return authConfig.publicRoutes.some((route) => pathname.includes(route));
|
|
};
|
|
|
|
export const isProtectedRoute = (pathname: string): boolean => {
|
|
return authConfig.protectedRoutes.some((route) => pathname.includes(route));
|
|
};
|