fix: Make routing-form a preinstalled app (#9836)
Co-authored-by: zomars <[email protected]>
This commit is contained in:
1 parent
9c389c307c
commit
f1acedff77
16 files changed
+70
-77
No files matched your search
+23
-5
@@ -54,10 +54,9 @@ const middleware: NextMiddleware = async (req) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 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");
|
||||
return NextResponse.rewrite(url);
|
||||
const res = routingForms.handle(url);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (url.pathname.startsWith("/api/trpc/")) {
|
||||
@@ -76,15 +75,34 @@ const middleware: NextMiddleware = async (req) => {
|
||||
});
|
||||
};
|
||||
|
||||
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/");
|
||||
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/");
|
||||
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 = {
|
||||
matcher: [
|
||||
"/((?!_next|.*avatar.png$|favicon.ico$).*)",
|
||||
"/api/collect-events/:path*",
|
||||
"/api/auth/:path*",
|
||||
"/apps/routing_forms/:path*",
|
||||
"/:path*/embed",
|
||||
"/api/trpc/:path*",
|
||||
"/auth/login",
|
||||
...routingForms.paths,
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user