forked from cardosofelipe/fast-next-template
- Remove persist middleware from authStore (causing hooks timing issues) - Restore original AuthInitializer component pattern - Keep good Phase 3 optimizations: - Theme FOUC fix (inline script) - React Query refetchOnWindowFocus disabled - Code splitting for dev/auth components - Shared form components (FormField, useFormError) - Store location in lib/stores
23 lines
543 B
TypeScript
23 lines
543 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import type { NextRequest } from 'next/server';
|
|
|
|
export function middleware(request: NextRequest) {
|
|
const { pathname } = request.nextUrl;
|
|
|
|
// Block access to /dev routes in production
|
|
if (pathname.startsWith('/dev')) {
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
|
|
if (isProduction) {
|
|
// Return 404 in production
|
|
return new NextResponse(null, { status: 404 });
|
|
}
|
|
}
|
|
|
|
return NextResponse.next();
|
|
}
|
|
|
|
export const config = {
|
|
matcher: '/dev/:path*',
|
|
};
|