Skip to content

Scheduling infrastructure for absolutely everyone.

fix: middleware logic Routing Forms (#10412)

Hariom Balhara48b79b618f15
diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts
index d877adde6d5..602bc1b1e4c 100644
--- a/apps/web/middleware.ts
+++ b/apps/web/middleware.ts
@@ -79,22 +79,22 @@ const routingForms = {
handle: (url: URL) => {
// Next.config.js Redirects don't handle Client Side navigations and we need that.
// So, we add the rewrite here instead.
- if (url.pathname.startsWith("/routing-forms/")) {
- url.pathname = url.pathname.replace(/^\/routing-forms\//, "/apps/routing-forms/");
+ if (url.pathname.startsWith("/routing-forms")) {
+ url.pathname = url.pathname.replace(/^\/routing-forms($|\/)/, "/apps/routing-forms/");
return NextResponse.rewrite(url);
}
// Don't 404 old routing_forms links
if (url.pathname.startsWith("/apps/routing_forms")) {
- url.pathname = url.pathname.replace(/^\/apps\/routing_forms\//, "/apps/routing-forms/");
+ url.pathname = url.pathname.replace(/^\/apps\/routing_forms($|\/)/, "/apps/routing-forms/");
return NextResponse.rewrite(url);
}
},
- // Matcher paths that are required by the handle function to work
- paths: ["/apps/routing_forms/:path*", "/routing-forms/:path*"],
};
export const config = {
+ // Next.js Doesn't support spread operator in config matcher, so, we must list all paths explicitly here.
+ // https://github.com/vercel/next.js/discussions/42458
matcher: [
"/((?!_next|.*avatar.png$|favicon.ico$).*)",
"/api/collect-events/:path*",
@@ -102,7 +102,12 @@ export const config = {
"/:path*/embed",
"/api/trpc/:path*",
"/auth/login",
- ...routingForms.paths,
+
+ /**
+ * Paths required by routingForms.handle
+ */
+ "/apps/routing_forms/:path*",
+ "/routing-forms/:path*",
],
};