Merged in fix/LOY-483-only-english (pull request #3194)
Fix/LOY-483: Fix My Pages working in all languages * fix(LOY-483): add back specific handling of profile pages * fix(LOY-483): remove limit of 1 profiling consent config Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
@@ -3,6 +3,9 @@ import { type NextMiddleware, NextResponse } from "next/server"
|
||||
import {
|
||||
myPages,
|
||||
overview,
|
||||
profile,
|
||||
profileConsent,
|
||||
profileEdit,
|
||||
} from "@scandic-hotels/common/constants/routes/myPages"
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
import { findLang } from "@scandic-hotels/common/utils/languages"
|
||||
@@ -49,6 +52,32 @@ export const middleware: NextMiddleware = async (request) => {
|
||||
headers.set("x-uid", uid)
|
||||
headers.set("x-contenttype", contentType)
|
||||
|
||||
if (profile[lang].startsWith(nextUrl.pathname)) {
|
||||
return NextResponse.rewrite(new URL(`/${lang}/my-pages/profile`, nextUrl), {
|
||||
request: {
|
||||
headers,
|
||||
},
|
||||
})
|
||||
} else if (profileEdit[lang].startsWith(nextUrl.pathname)) {
|
||||
return NextResponse.rewrite(
|
||||
new URL(`/${lang}/my-pages/profile/edit`, nextUrl),
|
||||
{
|
||||
request: {
|
||||
headers,
|
||||
},
|
||||
}
|
||||
)
|
||||
} else if (profileConsent[lang].startsWith(nextUrl.pathname)) {
|
||||
return NextResponse.rewrite(
|
||||
new URL(`/${lang}/my-pages/profile/consent`, nextUrl),
|
||||
{
|
||||
request: {
|
||||
headers,
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return NextResponse.next({
|
||||
request: {
|
||||
headers,
|
||||
|
||||
Reference in New Issue
Block a user