feat(ADM-018): completed feature
This commit is contained in:
15
project/storefront/src/proxy.ts
Normal file
15
project/storefront/src/proxy.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { NextResponse, type NextRequest } from 'next/server';
|
||||
import { EnvRedirectRepository } from '@/lib/seo/redirects';
|
||||
|
||||
const redirects = new EnvRedirectRepository();
|
||||
|
||||
export function proxy(request: NextRequest) {
|
||||
const redirect = redirects.findBySourcePath(request.nextUrl.pathname);
|
||||
if (!redirect) return NextResponse.next();
|
||||
|
||||
return NextResponse.redirect(new URL(redirect.to, request.url), 301);
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ['/((?!api/revalidate|_next/static|_next/image|favicon.ico).*)'],
|
||||
};
|
||||
Reference in New Issue
Block a user