fix: Broken Embed Dialog in Routing Forms due to recent rewrite (#10434)

Co-authored-by: zomars <[email protected]>
This commit is contained in:
Hariom Balharaandzomars authored and GitHub committed 2023-08-02 19:40:53 +00:00
1 parent ea7853789c
commit a56b19e618
8 files changed
+45 -17

No files matched your search

-8
View File
@@ -54,13 +54,6 @@ 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/");
@@ -80,7 +73,6 @@ export const config = {
* Paths required by routingForms.handle
*/
"/apps/routing_forms/:path*",
"/routing-forms/:path*",
],
};
@@ -0,0 +1,25 @@
import type { GetServerSidePropsContext } from "next";
import z from "zod";
const paramsSchema = z
.object({
pages: z.array(z.string()),
})
.catch({
pages: [],
});
export default function RoutingForms() {
return null;
}
export const getServerSideProps = (context: GetServerSidePropsContext) => {
const { pages } = paramsSchema.parse(context.params);
return {
redirect: {
destination: `/apps/routing-forms/${pages.length ? pages.join("/") : ""}`,
permanent: false,
},
};
};
+12
View File
@@ -0,0 +1,12 @@
export default function RoutingFormsIndex() {
return null;
}
export const getServerSideProps = () => {
return {
redirect: {
destination: `/apps/routing-forms/forms`,
permanent: false,
},
};
};