fix: send searchparams in rewrite

This commit is contained in:
Christel Westerberg
2024-05-28 11:00:27 +02:00
parent 97db9f21b9
commit f04247ed43
4 changed files with 33 additions and 6 deletions

View File

@@ -23,11 +23,17 @@ export const middleware: NextMiddleware = async (request) => {
// If user is redirected to /lang/webview/refresh/, the webview token is invalid and we remove the cookie
if (refreshWebviews.includes(nextUrl.pathname)) {
return NextResponse.rewrite(new URL(`/${lang}/webview/refresh`, nextUrl), {
headers: {
"Set-Cookie": `webviewToken=0; Max-Age=0; Secure; HttpOnly; Path=/; SameSite=Strict;`,
},
})
return NextResponse.rewrite(
new URL(
`/${lang}/webview/refresh?${nextUrl.searchParams.toString()}`,
nextUrl
),
{
headers: {
"Set-Cookie": `webviewToken=0; Max-Age=0; Secure; HttpOnly; Path=/; SameSite=Strict;`,
},
}
)
}
const pathNameWithoutLang = nextUrl.pathname.replace(`/${lang}/webview`, "")
@@ -73,6 +79,7 @@ export const middleware: NextMiddleware = async (request) => {
// It should be base64 encoded
const authorization = request.headers.get("Authorization")!
if (!authorization) {
console.error("Authorization header is missing")
return badRequest()
}
@@ -80,6 +87,7 @@ export const middleware: NextMiddleware = async (request) => {
// It should be base64 encoded
const initializationVector = request.headers.get("X-AES-IV")!
if (!initializationVector) {
console.error("initializationVector header is missing")
return badRequest()
}