Skip to content

Commit 456ceff

Browse files
committed
Revert "feat: enhance middleware to handle origin and path normalization"
This reverts commit 77ab23b.
1 parent 77ab23b commit 456ceff

1 file changed

Lines changed: 1 addition & 20 deletions

File tree

apps/media/middleware.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,11 @@ export default async function middleware(req: NextRequest) {
1717
return NextResponse.next();
1818
}
1919

20-
// Get the correct origin from Vercel's forwarded headers (when accessed via rewrites)
21-
const forwardedHost = req.headers.get("x-forwarded-host");
22-
const origin = forwardedHost
23-
? `${req.headers.get("x-forwarded-proto") || "https"}://${forwardedHost}`
24-
: req.nextUrl.origin;
25-
2620
// Lowercase all paths
2721
if (pathname !== pathname.toLowerCase()) {
2822
return NextResponse.redirect(
29-
new URL(pathname.toLowerCase() + req.nextUrl.search, origin)
30-
);
31-
}
32-
33-
// If origin differs, create a modified request so next-intl uses the correct domain
34-
if (origin !== req.nextUrl.origin) {
35-
const modifiedUrl = new URL(
36-
req.nextUrl.pathname + req.nextUrl.search,
37-
origin
23+
new URL(pathname.toLowerCase() + req.nextUrl.search, req.url)
3824
);
39-
const modifiedReq = new NextRequest(modifiedUrl, {
40-
headers: req.headers,
41-
method: req.method,
42-
});
43-
return handleI18nRouting(modifiedReq);
4425
}
4526

4627
// Let next-intl handle locale detection and routing

0 commit comments

Comments
 (0)