From 59b0ab3d495de6500b474046fb6d56426f64d4cb Mon Sep 17 00:00:00 2001 From: Arvid Norlin Date: Tue, 29 Apr 2025 11:12:56 +0000 Subject: [PATCH] Merged in fix/redirect-public-url (pull request #1902) fix: add getPublicNextURL for redirect url * fix(SW-2540): add getPublicNextURL for redirect url Approved-by: Michael Zetterberg --- apps/scandic-web/middlewares/redirect.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/scandic-web/middlewares/redirect.ts b/apps/scandic-web/middlewares/redirect.ts index b979ac856..725f29525 100644 --- a/apps/scandic-web/middlewares/redirect.ts +++ b/apps/scandic-web/middlewares/redirect.ts @@ -1,6 +1,7 @@ import { type NextMiddleware, NextResponse } from "next/server" import { notFound } from "@/server/errors/next" +import { getPublicNextURL } from "@/server/utils" import { getCacheClient } from "@/services/dataCache" import { findLang } from "@/utils/languages" @@ -52,7 +53,7 @@ export const middleware: NextMiddleware = async (request) => { ) if (matchedRedirect) { - const newUrl = new URL(matchedRedirect, request.nextUrl) + const newUrl = new URL(matchedRedirect, getPublicNextURL(request)) headers.set("Cache-control", "public, max-age=60") return NextResponse.redirect(newUrl, { headers,