fx 404 for embed (#20120)

This commit is contained in:
Hariom Balhara authored and GitHub committed 2025-04-20 16:16:48 +00:00
1 parent 51212cdacf
commit a77bd7bbe0
2 files changed
+13 -3

No files matched your search

+9 -2
View File
@@ -52,15 +52,22 @@ function getRegExpMatchingAllReservedRoutes(suffix) {
// Following routes don't exist but they work by doing rewrite. Thus they need to be excluded from matching the orgRewrite patterns
// Make sure to keep it upto date as more nonExistingRouteRewrites are added.
const otherNonExistingRoutePrefixes = ["forms", "router", "success", "cancel"];
// Most files/dirs in public dir must not be rewritten to org pages. Ideally it should be all the content of public dir, but that can be done later
// It is important to exclude the embed pages separately here because with SINGLE_ORG_SLUG enabled, the entire domain is eligible for rewrite vs just the org subdomain otherwise
const staticAssets = ["embed"];
// FIXME: I am not sure why public is needed here, an asset 'test' in public isn't accessible through "/public/test" but only through "/test"
// We should infact scan through all files in public and exclude them instead.
const nextJsSpecialPaths = ["_next", "public"];
let beforeRewriteExcludePages = pages.concat(otherNonExistingRoutePrefixes).concat(nextJsSpecialPaths);
let beforeRewriteExcludePages = pages
.concat(otherNonExistingRoutePrefixes)
.concat(nextJsSpecialPaths)
.concat(staticAssets);
return beforeRewriteExcludePages.join(`${suffix}|`) + suffix;
}
// To handle /something
exports.orgUserRoutePath = `/:user((?!${getRegExpMatchingAllReservedRoutes("/?$")})[a-zA-Z0-9\-_]+)`;
// To handle /something/somethingelse
exports.orgUserTypeRoutePath = `/:user((?!${getRegExpMatchingAllReservedRoutes(
"/"
+4 -1
View File
@@ -92,7 +92,7 @@ describe("next.config.js - Org Rewrite", () => {
});
describe("Rewrite", () => {
it("booking pages", () => {
it("Booking pages", () => {
expect(orgUserTypeRouteMatch("/user/type")?.params).toEqual({
user: "user",
type: "type",
@@ -137,6 +137,9 @@ describe("next.config.js - Org Rewrite", () => {
it("Non booking pages", () => {
expect(orgUserTypeRouteMatch("/_next/def")).toEqual(false);
expect(orgUserTypeRouteMatch("/public/def")).toEqual(false);
expect(orgUserRouteMatch("/embed.js")).toEqual(false);
expect(orgUserTypeRouteMatch("/embed/embed.js")).toEqual(false);
expect(orgUserTypeRouteMatch("/embed/preview.html")).toEqual(false);
expect(orgUserRouteMatch("/_next/")).toEqual(false);
expect(orgUserRouteMatch("/public/")).toEqual(false);