dev experience
This commit is contained in:
@@ -64,7 +64,17 @@ export function isAlpha(): boolean {
|
||||
*/
|
||||
export function getPublicRoutes(): readonly string[] {
|
||||
return [
|
||||
// Core public pages
|
||||
'/',
|
||||
|
||||
// Public content routes (leagues, drivers, teams, leaderboards, races)
|
||||
'/leagues',
|
||||
'/drivers',
|
||||
'/teams',
|
||||
'/leaderboards',
|
||||
'/races',
|
||||
|
||||
// Auth routes
|
||||
'/api/signup',
|
||||
'/api/auth/signup',
|
||||
'/api/auth/login',
|
||||
@@ -85,8 +95,27 @@ export function getPublicRoutes(): readonly string[] {
|
||||
|
||||
/**
|
||||
* Check if a route is public (accessible in all modes)
|
||||
* Supports both exact matches and prefix matches for nested routes
|
||||
*/
|
||||
export function isPublicRoute(pathname: string): boolean {
|
||||
const publicRoutes = getPublicRoutes();
|
||||
return publicRoutes.includes(pathname);
|
||||
|
||||
// Check exact match first
|
||||
if (publicRoutes.includes(pathname)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check prefix matches for nested routes
|
||||
// e.g., '/leagues' should match '/leagues/123', '/leagues/create', etc.
|
||||
const publicPrefixes = [
|
||||
'/leagues',
|
||||
'/drivers',
|
||||
'/teams',
|
||||
'/leaderboards',
|
||||
'/races',
|
||||
];
|
||||
|
||||
return publicPrefixes.some(prefix =>
|
||||
pathname === prefix || pathname.startsWith(prefix + '/')
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user