Files
web/apps/scandic-web/components/LanguageSwitcher/setLanguageCookie.ts
emma.zettervall b72f4c71e3 Merged in feat/book-245-preferred-lang-redirect (pull request #2861)
Feat/book 245 preferred lang redirect

* added cookie to save preferredLang and middleware to route accordingly

* Cleaned up code, added noValidLang.ts middleware

* cleaned a little more

* Added headers in languageRedirect and set language cookie maxAge to 1 year


Approved-by: Linus Flood
2025-09-26 08:00:25 +00:00

10 lines
257 B
TypeScript

"use server"
import { cookies } from "next/headers"
export async function setLanguageCookie(preferredLang: string) {
const cookieStore = await cookies()
cookieStore.set("preferredLang", preferredLang, {
maxAge: 60 * 60 * 24 * 365, // 1 year
})
}