fix(auth): make things work
This commit is contained in:
+8
-1
@@ -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),
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user