fix: middleware logic Routing Forms (#10412)
* Match /apps/routing_forms * Next.js config.matcher doesnt support spread operatorpull/10413/head
parent
98a156311d
commit
48b79b618f
|
@ -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*",
|
||||
],
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue