Skip to content

Commit 2d9c1b3

Browse files
feat: Make single org setup more reliable by automatically adjusting RESERVED_SUBDOMAINS and ORGANIZATIONS_ENABLED (calcom#23448)
* feat: add build validation for SINGLE_ORG_SLUG and auto-enable organizations - Add build-time validation to prevent SINGLE_ORG_SLUG from conflicting with RESERVED_SUBDOMAINS - Auto-enable ORGANIZATIONS_ENABLED when SINGLE_ORG_SLUG is set - Validation throws clear error message with list of reserved subdomains - Follows existing environment validation patterns in next.config.js Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * refactor: change SINGLE_ORG_SLUG validation from error to warning - Replace build-crashing error with clear warning message - Ignore RESERVED_SUBDOMAINS when SINGLE_ORG_SLUG is set since they don't make sense together - Keep auto-enabling ORGANIZATIONS_ENABLED functionality - Build continues successfully instead of failing Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * Update next.config.js * Update next.config.js --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent f2f10a0 commit 2d9c1b3

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

apps/web/next.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const {
1111
orgUserTypeRoutePath,
1212
orgUserTypeEmbedRoutePath,
1313
} = require("./pagesAndRewritePaths");
14+
15+
adjustEnvVariables();
16+
1417
if (!process.env.NEXTAUTH_SECRET) throw new Error("Please set NEXTAUTH_SECRET");
1518
if (!process.env.CALENDSO_ENCRYPTION_KEY) throw new Error("Please set CALENDSO_ENCRYPTION_KEY");
1619
const isOrganizationsEnabled =
@@ -715,4 +718,22 @@ const nextConfig = (phase) => {
715718
};
716719
};
717720

721+
function adjustEnvVariables() {
722+
if (process.env.NEXT_PUBLIC_SINGLE_ORG_SLUG) {
723+
if (process.env.RESERVED_SUBDOMAINS) {
724+
// It is better to ignore it completely so that accidentally if the org slug is itself in Reserved Subdomain that doesn't cause the booking pages to start giving 404s
725+
console.warn(
726+
`⚠️ WARNING: RESERVED_SUBDOMAINS is ignored when SINGLE_ORG_SLUG is set. Single org mode doesn't need to use reserved subdomain validation.`
727+
);
728+
delete process.env.RESERVED_SUBDOMAINS;
729+
}
730+
731+
if (!process.env.ORGANIZATIONS_ENABLED) {
732+
// This is basically a consent to add rewrites related to organizations. So, if single org slug mode is there, we have the consent already.
733+
console.log("Auto-enabling ORGANIZATIONS_ENABLED because SINGLE_ORG_SLUG is set");
734+
process.env.ORGANIZATIONS_ENABLED = "1";
735+
}
736+
}
737+
}
738+
718739
module.exports = (phase) => plugins.reduce((acc, next) => next(acc), nextConfig(phase));

0 commit comments

Comments
 (0)