Change /photos paths to rewrites

This commit is contained in:
Sam Becker 2023-09-10 14:31:54 -05:00
parent aacee2f63f
commit 2f513e2b39

View File

@ -8,9 +8,9 @@ export default function middleware(req: NextRequest, res:NextResponse) {
if (pathname === '/admin') {
return NextResponse.redirect(new URL('/admin/photos', req.url));
} else if (/^\/photos\/(.)+$/.test(pathname)) {
// Accept full /photos/* paths, but redirect to /p/*
// Accept /photos/* paths, but serve /p/*
const matches = pathname.match(/^\/photos\/(.+)$/);
return NextResponse.redirect(new URL(
return NextResponse.rewrite(new URL(
`/p/${matches?.[1]}`,
req.url,
));