Skip to content

Scheduling infrastructure for absolutely everyone.

fix: include app directory in rewrites generation logic + migrate /reschedule pages to App Router (#18261)

Benny Joo355aaa701097
diff --git a/apps/web/app/future/reschedule/[uid]/embed/page.tsx b/apps/web/app/reschedule/[uid]/embed/page.tsx
similarity index 51%
rename from apps/web/app/future/reschedule/[uid]/embed/page.tsx
rename to apps/web/app/reschedule/[uid]/embed/page.tsx
index 52f7f7e1d93..0ec1cff1f69 100644
--- a/apps/web/app/future/reschedule/[uid]/embed/page.tsx
+++ b/apps/web/app/reschedule/[uid]/embed/page.tsx
@@ -1,15 +1,17 @@
-import { getServerSideProps as _getServerSideProps } from "@pages/reschedule/[uid]";
+import { withAppDirSsr } from "app/WithAppDirSsr";
+import withEmbedSsrAppDir from "app/WithEmbedSSR";
import type { PageProps } from "app/_types";
import { cookies, headers } from "next/headers";
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
-import withEmbedSsr from "@lib/withEmbedSsr";
+import { getServerSideProps } from "@lib/reschedule/[uid]/getServerSideProps";
-const getData = withEmbedSsr(_getServerSideProps);
+const getData = withAppDirSsr(getServerSideProps);
+const getEmbedData = withEmbedSsrAppDir(getData);
const Page = async ({ params, searchParams }: PageProps) => {
const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams);
- await getData(legacyCtx);
+ await getEmbedData(legacyCtx);
return null;
};
diff --git a/apps/web/app/future/reschedule/[uid]/page.tsx b/apps/web/app/reschedule/[uid]/page.tsx
similarity index 78%
rename from apps/web/app/future/reschedule/[uid]/page.tsx
rename to apps/web/app/reschedule/[uid]/page.tsx
index 4f629a3ba0f..4e03ebe7a4a 100644
--- a/apps/web/app/future/reschedule/[uid]/page.tsx
+++ b/apps/web/app/reschedule/[uid]/page.tsx
@@ -1,17 +1,10 @@
import { withAppDirSsr } from "app/WithAppDirSsr";
import type { PageProps } from "app/_types";
-import { _generateMetadata } from "app/_utils";
import { headers, cookies } from "next/headers";
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
import { getServerSideProps } from "@lib/reschedule/[uid]/getServerSideProps";
-export const generateMetadata = async () =>
- await _generateMetadata(
- () => "",
- () => ""
- );
-
const getData = withAppDirSsr(getServerSideProps);
const Page = async ({ params, searchParams }: PageProps) => {
diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts
index 276aa633248..3b007c37743 100644
--- a/apps/web/middleware.ts
+++ b/apps/web/middleware.ts
@@ -192,6 +192,7 @@ export const config = {
"/teams",
"/future/teams/",
"/settings/:path*",
+ "/reschedule/:path*",
"/availability/:path*",
"/booking/:path*",
],
diff --git a/apps/web/pages/reschedule/[uid].tsx b/apps/web/pages/reschedule/[uid].tsx
deleted file mode 100644
index 1105adaa4ca..00000000000
--- a/apps/web/pages/reschedule/[uid].tsx
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function Type() {
- // Just redirect to the schedule page to reschedule it.
- return null;
-}
-
-export { getServerSideProps } from "@lib/reschedule/[uid]/getServerSideProps";
diff --git a/apps/web/pages/reschedule/[uid]/embed.tsx b/apps/web/pages/reschedule/[uid]/embed.tsx
deleted file mode 100644
index 5d6b405e570..00000000000
--- a/apps/web/pages/reschedule/[uid]/embed.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-import withEmbedSsr from "@lib/withEmbedSsr";
-
-import { getServerSideProps as _getServerSideProps } from "../[uid]";
-
-export { default } from "../[uid]";
-
-export const getServerSideProps = withEmbedSsr(_getServerSideProps);
diff --git a/apps/web/pagesAndRewritePaths.js b/apps/web/pagesAndRewritePaths.js
index 96f8b48083e..44c0342fd23 100644
--- a/apps/web/pagesAndRewritePaths.js
+++ b/apps/web/pagesAndRewritePaths.js
@@ -1,15 +1,31 @@
const glob = require("glob");
const { getSubdomainRegExp } = require("./getSubdomainRegExp");
/** Needed to rewrite public booking page, gets all static pages but [user] */
+// Pages found here are excluded from redirects in beforeFiles in next.config.js
let pages = (exports.pages = glob
- .sync("pages/**/[^_]*.{tsx,js,ts}", { cwd: __dirname })
+ .sync("{pages,app}/**/[^_]*.{tsx,js,ts}", { cwd: __dirname })
.map((filename) =>
filename
- .substr(6)
+ .replace(/^(pages|app)\//, "")
.replace(/(\.tsx|\.js|\.ts)/, "")
.replace(/\/.*/, "")
)
- .filter((v, i, self) => self.indexOf(v) === i && !v.startsWith("[user]")));
+ // "/future" is a temporary directory for incremental migration to App Router
+ .filter(
+ (v, i, self) =>
+ self.indexOf(v) === i &&
+ ![
+ "[user]",
+ "future",
+ "_trpc",
+ "layout",
+ "layoutHOC",
+ "WithAppDirSsg",
+ "global-error",
+ "WithAppDirSsr",
+ "WithEmbedSSR",
+ ].some((prefix) => v.startsWith(prefix))
+ ));
// .* matches / as well(Note: *(i.e wildcard) doesn't match / but .*(i.e. RegExp) does)
// It would match /free/30min but not /bookings/upcoming because 'bookings' is an item in pages
diff --git a/apps/web/test/lib/pagesAndRewritePaths.test.ts b/apps/web/test/lib/pagesAndRewritePaths.test.ts
new file mode 100644
index 00000000000..55eabe63c8d
--- /dev/null
+++ b/apps/web/test/lib/pagesAndRewritePaths.test.ts
@@ -0,0 +1,45 @@
+import { it, expect, describe } from "vitest";
+
+import { pages } from "../../pagesAndRewritePaths.js";
+
+describe("pagesAndRewritePaths", () => {
+ describe("beforeFiles must exclude routes in pages/app router", () => {
+ const BEFORE_REWRITE_EXCLUDE_PAGES = [
+ "apps",
+ "availability",
+ "booking",
+ "connect-and-join",
+ "enterprise",
+ "error",
+ "getting-started",
+ "insights",
+ "maintenance",
+ "more",
+ "not-found",
+ "reschedule",
+ "settings",
+ "teams",
+ "upgrade",
+ "video",
+ "workflows",
+ "403",
+ "404",
+ "500",
+ "bookings",
+ "event-types",
+ "icons",
+ "org",
+ "payment",
+ "routing-forms",
+ "signup",
+ "team",
+ "d",
+ ];
+
+ it("should include all required routes", () => {
+ BEFORE_REWRITE_EXCLUDE_PAGES.forEach((route) => {
+ expect(pages).toContain(route);
+ });
+ });
+ });
+});