diff --git a/apps/homepage/next.config.ts b/apps/homepage/next.config.ts index 39dbbf2..df98054 100644 --- a/apps/homepage/next.config.ts +++ b/apps/homepage/next.config.ts @@ -46,16 +46,6 @@ const nextConfig: NextConfig = { destination: '/dashboard/:path*', permanent: false, }, - { - source: '/sign-in', - destination: '/en/sign-in', - permanent: false, - }, - { - source: '/forgot-password', - destination: '/en/forgot-password', - permanent: false, - }, ]; }, diff --git a/apps/homepage/public/rentaldrivego.jpeg b/apps/homepage/public/rentaldrivego.jpeg new file mode 100644 index 0000000..4547894 Binary files /dev/null and b/apps/homepage/public/rentaldrivego.jpeg differ diff --git a/apps/homepage/src/components/app-shell/AuthHeader.tsx b/apps/homepage/src/components/app-shell/AuthHeader.tsx index eb870c7..1b0c15a 100644 --- a/apps/homepage/src/components/app-shell/AuthHeader.tsx +++ b/apps/homepage/src/components/app-shell/AuthHeader.tsx @@ -1,6 +1,7 @@ 'use client'; import { localizedPath, locales, type Locale } from '@/lib/localization/config'; +import { persistLocale } from '@/lib/localization/client'; import { persistTheme, themePreferenceEvent } from '@/lib/theme/client'; import { type ThemePreference } from '@/lib/theme/config'; import Image from 'next/image'; @@ -62,6 +63,7 @@ export function AuthHeader({ locale, themePreference: initialPref }: Props) { const switchLocale = (next: Locale) => { setLocaleOpen(false); + persistLocale(next); const segments = pathname.split('/').filter(Boolean); if (segments.length >= 2) segments[1] = next; router.push('/' + segments.join('/')); diff --git a/apps/homepage/src/components/app-shell/HeaderRouter.tsx b/apps/homepage/src/components/app-shell/HeaderRouter.tsx index 85c2a5a..f085fda 100644 --- a/apps/homepage/src/components/app-shell/HeaderRouter.tsx +++ b/apps/homepage/src/components/app-shell/HeaderRouter.tsx @@ -3,6 +3,7 @@ import { usePathname } from 'next/navigation'; import { SiteHeader } from './SiteHeader'; import { AuthHeader } from './AuthHeader'; +import { routeIdFromPathname } from '@/lib/localization/config'; import type { ShellMessages } from '@/lib/localization/messages'; import type { Locale } from '@/lib/localization/config'; import type { ThemePreference } from '@/lib/theme/config'; @@ -15,7 +16,8 @@ interface Props { export function HeaderRouter({ locale, messages, themePreference }: Props) { const pathname = usePathname(); - const isAuth = pathname.endsWith('/sign-in') || pathname.endsWith('/forgot-password'); + const routeId = routeIdFromPathname(pathname); + const isAuth = routeId === 'sign-in' || routeId === 'forgot-password'; if (isAuth) { return ; diff --git a/apps/homepage/src/components/app-shell/SiteHeader.module.css b/apps/homepage/src/components/app-shell/SiteHeader.module.css index 1db29d7..fa43c84 100644 --- a/apps/homepage/src/components/app-shell/SiteHeader.module.css +++ b/apps/homepage/src/components/app-shell/SiteHeader.module.css @@ -61,6 +61,7 @@ color: var(--text-primary); font-weight: 650; text-decoration: none; + white-space: nowrap; } .navigation a { diff --git a/apps/homepage/src/proxy.ts b/apps/homepage/src/proxy.ts index bc86433..3b75c2e 100644 --- a/apps/homepage/src/proxy.ts +++ b/apps/homepage/src/proxy.ts @@ -44,6 +44,19 @@ export function proxy(request: NextRequest): NextResponse { return applySecurityHeaders(response, csp); } + // Redirect locale-less paths (e.g. /sign-in → /en/sign-in), but not /dashboard, /admin, or files + const firstSegment = request.nextUrl.pathname.split('/')[1]; + const isFile = /\.\w+$/.test(request.nextUrl.pathname); + if (firstSegment && !isFile && !isLocale(firstSegment) && firstSegment !== 'dashboard' && firstSegment !== 'admin') { + const cookieLocale = request.cookies.get(localeCookie)?.value; + const locale = isLocale(cookieLocale) + ? cookieLocale + : localeFromAcceptLanguage(request.headers.get('accept-language')) || defaultLocale; + const destination = request.nextUrl.clone(); + destination.pathname = `/${locale}${request.nextUrl.pathname}`; + return applySecurityHeaders(NextResponse.redirect(destination), csp); + } + const response = NextResponse.next({ request: { headers: requestHeaders } }); const explicitLocale = request.nextUrl.pathname.split('/')[1]; if (isLocale(explicitLocale)) {