Doceditor: fix double base path in URL for firefox

This commit is contained in:
Timofey Boyko 2024-07-01 16:42:35 +03:00
parent 7a736f2271
commit 5558e063a6
2 changed files with 19 additions and 2 deletions

View File

@ -121,6 +121,9 @@ async function Page({ searchParams }: { searchParams: TSearchParams }) {
}
const redirectURL = `/doceditor?${searchParams.toString()}`;
console.log("====", redirectURL);
return permanentRedirect(redirectURL);
}

View File

@ -29,10 +29,24 @@ import type { NextRequest } from "next/server";
// This function can be marked `async` if using `await` inside
export function middleware(request: NextRequest) {
return NextResponse.json({ status: "healthy" }, { status: 200 });
const host = request.headers.get("x-forwarded-host");
const proto = request.headers.get("x-forwarded-proto");
const redirectUrl = `${proto}://${host}`;
if (request.nextUrl.pathname === "/health") {
console.log("Get doceditor health check for portal: ", redirectUrl);
return NextResponse.json({ status: "healthy" }, { status: 200 });
}
if (request.nextUrl.pathname.includes("doceditor")) {
return NextResponse.redirect(
`${redirectUrl}/doceditor${request.nextUrl.search}`,
);
}
}
// See "Matching Paths" below to learn more
export const config = {
matcher: "/health",
matcher: ["/health", "/doceditor"],
};