metaforecast/src/pages/_middleware.ts

18 lines
451 B
TypeScript
Raw Normal View History

2022-04-09 22:50:13 +00:00
import { NextRequest, NextResponse } from "next/server";
export async function middleware(req: NextRequest) {
const { pathname, searchParams } = req.nextUrl;
console.log(pathname);
if (pathname === "/dashboards") {
const dashboardId = searchParams.get("dashboardId");
if (dashboardId) {
return NextResponse.redirect(
new URL(`/dashboards/view/${dashboardId}`, req.url)
);
}
}
return NextResponse.next();
}