Fixes: - Add dynamic export to dashboard page to prevent Next.js pre-rendering - Fixes critical auth bypass where cached page was served to all users - Document middleware response propagation trade-off QA Issues Fixed: - Issue #1: Dashboard page pre-rendering bypasses authentication - Issue #3: Middleware response object not propagated (documented) Verified: - TypeScript compilation passes - Code follows Next.js 15 auth best practices - Middleware trade-off documented per QA recommendation QA Fix Session: 1 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { setRequestLocale } from 'next-intl/server';
|
|
import type { Metadata } from 'next';
|
|
import { redirect } from 'next/navigation';
|
|
import DashboardContent from '@/components/auth/DashboardContent';
|
|
import { createClient } from '@/lib/supabase/server';
|
|
|
|
// Force dynamic rendering to ensure auth checks run on every request
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
type Props = {
|
|
params: Promise<{ locale: string }>;
|
|
};
|
|
|
|
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
const { locale } = await params;
|
|
|
|
const titles: Record<string, string> = {
|
|
de: 'Dashboard | Damjan Savić',
|
|
en: 'Dashboard | Damjan Savić',
|
|
sr: 'Dashboard | Damjan Savić',
|
|
};
|
|
|
|
return {
|
|
title: titles[locale] || titles.de,
|
|
robots: {
|
|
index: false,
|
|
follow: false,
|
|
googleBot: {
|
|
index: false,
|
|
follow: false,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
export default async function DashboardPage({ params }: Props) {
|
|
const { locale } = await params;
|
|
setRequestLocale(locale);
|
|
|
|
// Server-side auth check (defense-in-depth)
|
|
const supabase = await createClient();
|
|
const { data: { user } } = await supabase.auth.getUser();
|
|
|
|
if (!user) {
|
|
redirect(`/${locale}/login`);
|
|
}
|
|
|
|
return <DashboardContent />;
|
|
}
|