fix(frontend): middleware rewrites remote actor URLs to avoid Next.js file-extension routing issue
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 31s
test / unit (pull_request) Failing after 11m18s
test / integration (pull_request) Failing after 18m1s

This commit is contained in:
2026-05-14 22:40:21 +02:00
parent 4ce239fc87
commit 072d06cb46
4 changed files with 59 additions and 26 deletions

View File

@@ -0,0 +1,23 @@
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
export function middleware(request: NextRequest) {
const parts = request.nextUrl.pathname.split("/");
// /users/@user@instance or /users/%40user%40instance
if (parts.length === 3 && parts[1] === "users") {
const decoded = decodeURIComponent(parts[2]);
if (decoded.startsWith("@") && decoded.indexOf("@", 1) !== -1) {
const url = request.nextUrl.clone();
url.pathname = "/remote-actor";
url.searchParams.set("handle", decoded);
return NextResponse.rewrite(url);
}
}
return NextResponse.next();
}
export const config = {
matcher: "/users/:path*",
};