diff --git a/apps/web/src/actions/auth/sign-in.ts b/apps/web/src/actions/auth/sign-in.ts
index f5edcc9b5..72eb6441d 100644
--- a/apps/web/src/actions/auth/sign-in.ts
+++ b/apps/web/src/actions/auth/sign-in.ts
@@ -13,6 +13,15 @@ type SignInInput = {
redirectTo?: string
}
+function getLocaleFromRedirectTo(redirectTo?: string) {
+ if (!redirectTo) return null
+
+ const locale = redirectTo.split('/').filter(Boolean)[0]
+ const isValidLocale = /^[a-z]{2}-[A-Z]{2}$/.test(locale ?? '')
+
+ return isValidLocale ? locale : null
+}
+
export async function signIn({ login, password, redirectTo }: SignInInput) {
let token: string | undefined
@@ -37,7 +46,9 @@ export async function signIn({ login, password, redirectTo }: SignInInput) {
if (data?.user && !data.user.displayName) {
const cookieStore = await cookies()
+ const localeFromRedirect = getLocaleFromRedirectTo(redirectTo)
const lang =
+ localeFromRedirect ||
cookieStore.get('NEXT_LOCALE')?.value ||
cookieStore.get('i18next')?.value ||
'en-US'
diff --git a/apps/web/src/app/[lang]/layout.tsx b/apps/web/src/app/[lang]/layout.tsx
index 7331e9f51..5606bc8a0 100644
--- a/apps/web/src/app/[lang]/layout.tsx
+++ b/apps/web/src/app/[lang]/layout.tsx
@@ -1,4 +1,3 @@
-import { headers } from 'next/headers'
import { Link } from 'next-view-transitions'
import type { GetUserPreferences200 } from '@/api/endpoints.schemas'
import { getUserPreferences } from '@/api/users'
@@ -43,10 +42,6 @@ export default async function RootLayout({
userPreferences = data?.userPreferences ?? null
}
- const headersList = await headers()
- const pathname = headersList.get('x-current-path') || ''
- const isOnboarding = pathname.includes('/onboarding')
-
return (
}
footer={}
- isOnboarding={isOnboarding}
proBadge={
session?.user.subscriptionType !== 'PRO' ? (
diff --git a/apps/web/src/components/layout-wrapper.tsx b/apps/web/src/components/layout-wrapper.tsx
index b0c3ced4f..3204129c3 100644
--- a/apps/web/src/components/layout-wrapper.tsx
+++ b/apps/web/src/components/layout-wrapper.tsx
@@ -1,16 +1,20 @@
+'use client'
+
+import { usePathname } from 'next/navigation'
+
export function LayoutWrapper({
header,
footer,
children,
proBadge,
- isOnboarding,
}: {
header: React.ReactNode
footer: React.ReactNode
children: React.ReactNode
proBadge?: React.ReactNode
- isOnboarding?: boolean
}) {
+ const pathname = usePathname()
+ const isOnboarding = pathname?.includes('/onboarding') ?? false
return (
<>