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
This commit is contained in:
emma.zettervall
2025-09-26 08:00:25 +00:00
parent 1746ed9803
commit b72f4c71e3
5 changed files with 70 additions and 21 deletions

View File

@@ -0,0 +1,9 @@
"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
})
}