Skip to content

Commit edc90e3

Browse files
Handle disabling of ORGANIZATIONS_ENABLED flag (#11041)
1 parent 05631d0 commit edc90e3

File tree

1 file changed

+36
-33
lines changed

1 file changed

+36
-33
lines changed

apps/web/next.config.js

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const {
1414

1515
if (!process.env.NEXTAUTH_SECRET) throw new Error("Please set NEXTAUTH_SECRET");
1616
if (!process.env.CALENDSO_ENCRYPTION_KEY) throw new Error("Please set CALENDSO_ENCRYPTION_KEY");
17-
17+
const isOrganizationsEnabled =
18+
process.env.ORGANIZATIONS_ENABLED === "1" || process.env.ORGANIZATIONS_ENABLED === "true";
1819
// To be able to use the version in the app without having to import package.json
1920
process.env.NEXT_PUBLIC_CALCOM_VERSION = version;
2021

@@ -226,7 +227,7 @@ const nextConfig = {
226227
async rewrites() {
227228
const beforeFiles = [
228229
// These rewrites are other than booking pages rewrites and so that they aren't redirected to org pages ensure that they happen in beforeFiles
229-
...(process.env.ORGANIZATIONS_ENABLED
230+
...(isOrganizationsEnabled
230231
? [
231232
{
232233
...matcherConfigRootPath,
@@ -333,44 +334,46 @@ const nextConfig = {
333334
},
334335
],
335336
},
336-
...[
337-
{
338-
...matcherConfigRootPath,
339-
headers: [
337+
...(isOrganizationsEnabled
338+
? [
340339
{
341-
key: "X-Cal-Org-path",
342-
value: "/team/:orgSlug",
340+
...matcherConfigRootPath,
341+
headers: [
342+
{
343+
key: "X-Cal-Org-path",
344+
value: "/team/:orgSlug",
345+
},
346+
],
343347
},
344-
],
345-
},
346-
{
347-
...matcherConfigUserRoute,
348-
headers: [
349348
{
350-
key: "X-Cal-Org-path",
351-
value: "/org/:orgSlug/:user",
349+
...matcherConfigUserRoute,
350+
headers: [
351+
{
352+
key: "X-Cal-Org-path",
353+
value: "/org/:orgSlug/:user",
354+
},
355+
],
352356
},
353-
],
354-
},
355-
{
356-
...matcherConfigUserTypeRoute,
357-
headers: [
358357
{
359-
key: "X-Cal-Org-path",
360-
value: "/org/:orgSlug/:user/:type",
358+
...matcherConfigUserTypeRoute,
359+
headers: [
360+
{
361+
key: "X-Cal-Org-path",
362+
value: "/org/:orgSlug/:user/:type",
363+
},
364+
],
361365
},
362-
],
363-
},
364-
{
365-
...matcherConfigUserTypeEmbedRoute,
366-
headers: [
367366
{
368-
key: "X-Cal-Org-path",
369-
value: "/org/:orgSlug/:user/:type/embed",
367+
...matcherConfigUserTypeEmbedRoute,
368+
headers: [
369+
{
370+
key: "X-Cal-Org-path",
371+
value: "/org/:orgSlug/:user/:type/embed",
372+
},
373+
],
370374
},
371-
],
372-
},
373-
],
375+
]
376+
: []),
374377
];
375378
},
376379
async redirects() {
@@ -463,7 +466,7 @@ const nextConfig = {
463466
// OAuth callbacks when sent to localhost:3000(w would be expected) should be redirected to corresponding to WEBAPP_URL
464467
...(process.env.NODE_ENV === "development" &&
465468
// Safer to enable the redirect only when the user is opting to test out organizations
466-
process.env.ORGANIZATIONS_ENABLED &&
469+
isOrganizationsEnabled &&
467470
// Prevent infinite redirect by checking that we aren't already on localhost
468471
process.env.NEXT_PUBLIC_WEBAPP_URL !== "http://localhost:3000"
469472
? [

0 commit comments

Comments
 (0)