The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
import { NextRequest, NextResponse } from "next/server";
import { parse } from "./utils/parse";
export function EmbedMiddleware(req: NextRequest) {
const { path, fullPath } = parse(req);
if (path.startsWith("/embed/support-chat")) {
return NextResponse.rewrite(new URL(`/app.dub.co${fullPath}`, req.url));
}
// TODO: Show token expiry page
return NextResponse.redirect(new URL("/", req.url));
}