Skip to content

Commit

Permalink
fix: adds search params to multisite rewrite in appMiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdubail committed Dec 6, 2024
1 parent 3d543e4 commit 7ef872b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/next/src/middlewares/appMidleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export async function AppMiddleware(
options: AppMidlewareOptions = { appRouter: false },
) {
let response = NextResponse.next();
const { pathname } = req.nextUrl;
const { pathname, searchParams } = req.nextUrl;

if (isStaticAssetRequest(req) || isInternalRequest(req)) {
return response;
Expand Down Expand Up @@ -193,8 +193,8 @@ export async function AppMiddleware(
const hostNameOrSlug = site.slug || hostname;
const pagesRouterRewrite = `/_sites/${hostNameOrSlug}${pathname}`;
const appRouterRewrite = locale
? `/${locale}/${hostNameOrSlug}${pathname.replace(`/${locale}`, '')}`
: `/${hostNameOrSlug}${pathname}`;
? `/${locale}/${hostNameOrSlug}${pathname.replace(`/${locale}`, '')}?${searchParams.toString()}`
: `/${hostNameOrSlug}${pathname}?${searchParams.toString()}`;

response = NextResponse.rewrite(
new URL(options.appRouter ? appRouterRewrite : pagesRouterRewrite, req.nextUrl),
Expand Down

0 comments on commit 7ef872b

Please sign in to comment.