diff --git a/src/app/[lang]/page.tsx b/src/app/[lang]/page.tsx
index a0099b7..af36864 100644
--- a/src/app/[lang]/page.tsx
+++ b/src/app/[lang]/page.tsx
@@ -7,10 +7,6 @@ import {
isAuthenticatedToken,
MARRIAGE_ENTRY_PATH_COOKIE,
} from "@/lib/entry-route-cache";
-import {
- getSubmitPath,
- hasCompletedMarriageProfileBasics,
-} from "@/lib/get-submit-path";
import { localizePath } from "@/translations/config";
export const dynamic = "force-dynamic";
@@ -34,38 +30,12 @@ export default async function LocaleEntryPage({
redirect(localizePath(cachedEntryPath, lang));
}
- // 1. If not authenticated, render instantly on the server (0ms client delay)
+ // 1. If not authenticated, render instantly in SSR (0ms client delay)
if (!hasToken) {
return ;
}
- // 2. If authenticated without cached route, resolve target route directly on the server
- let targetPath: string | null = null;
- const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
- if (apiBaseUrl) {
- try {
- const res = await fetch(`${apiBaseUrl}/api/marriage/profile/main/`, {
- headers: {
- Authorization: `Token ${token}`,
- Accept: "application/json",
- },
- cache: "no-store",
- });
- if (res.ok) {
- const profile = await res.json();
- targetPath = hasCompletedMarriageProfileBasics(profile)
- ? getSubmitPath(profile)
- : "/intro";
- }
- } catch {
- // Graceful fallback to client-side resolver if server fetch fails
- }
- }
-
- if (targetPath) {
- redirect(localizePath(targetPath, lang));
- }
-
+ // 2. If authenticated without cached route, deliver head/web_ready immediately and resolve in client
return (
<>
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 894b332..b42f0bf 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -2,6 +2,7 @@ import { cookies, headers } from "next/headers";
import { redirect } from "next/navigation";
import {
getAuthenticatedCachedEntryPath,
+ isAuthenticatedToken,
MARRIAGE_ENTRY_PATH_COOKIE,
} from "@/lib/entry-route-cache";
import {
@@ -36,14 +37,20 @@ export default async function RootPage() {
const token =
cookieStore.get("HABIB_TOKEN")?.value ??
cookieStore.get("habib_token")?.value;
+ const hasToken = isAuthenticatedToken(token);
+
+ if (!hasToken) {
+ redirect(`/${targetLocale}`);
+ }
+
const cachedEntryPath = getAuthenticatedCachedEntryPath(
token,
cookieStore.get(MARRIAGE_ENTRY_PATH_COOKIE)?.value,
);
- redirect(
- cachedEntryPath
- ? localizePath(cachedEntryPath, targetLocale)
- : `/${targetLocale}`,
- );
+ if (cachedEntryPath) {
+ redirect(localizePath(cachedEntryPath, targetLocale));
+ }
+
+ redirect(`/${targetLocale}`);
}