mirror of
https://github.com/hwchase17/langchain.git
synced 2026-02-21 22:56:05 +00:00
20 lines
483 B
JavaScript
20 lines
483 B
JavaScript
import { next } from "@vercel/edge";
|
|
import redirects from "./redirects.json";
|
|
|
|
export default function middleware(request) {
|
|
const url = new URL(request.url);
|
|
const pathname = url.pathname;
|
|
|
|
// Find matching redirect
|
|
const redirect = redirects.find((r) => {
|
|
const source = r.source.replace("(/?)", "");
|
|
return pathname === source || pathname === source + "/";
|
|
});
|
|
|
|
if (redirect) {
|
|
return Response.redirect(redirect.destination, 308);
|
|
}
|
|
|
|
return next();
|
|
}
|