fix(auth): make things work

This commit is contained in:
Michael Zetterberg
2024-05-20 09:05:49 +02:00
parent c4912bbb94
commit 476e9f7582
19 changed files with 122 additions and 82 deletions
+8 -1
View File
@@ -46,13 +46,20 @@ export const middleware: NextMiddleware = async (request, event) => {
// We use x-lang as either Akamai or Netlify use x-language as the users preferred language
result?.headers.set("x-lang", lang)
result?.headers.set("x-pathname", request.nextUrl.pathname)
result?.headers.set(
"x-pathname",
request.nextUrl.pathname.replace(`/${lang}`, "")
)
result?.headers.set("x-url", request.nextUrl.href)
return result
}
}
} catch (e) {
if (e instanceof NextResponse && e.status) {
const cause = await e.json()
console.error(`Error in middleware`)
console.error(cause)
return NextResponse.rewrite(
new URL(`/${lang}/middleware-error/${e.status}`, request.nextUrl),
{