fix: 404 booking pages when org support is enabled locally
## What does this PR do? Fix 404 booking pages when org support is enabled locally ## Type of change <!-- Please delete bullets that are not relevant. --> - Bug fix (non-breaking change which fixes an issue) ## How should this be tested? <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> - Add localhost:3000 to ALLOWED_HOSTNAMES which is the default recommendation for enabling org support locally. <img width="1035" alt="Screenshot 2023-07-10 at 11 04 35 AM" src="https://github.com/calcom/cal.com/assets/1780212/7272437b-afae-4073-905b-eafc39f9fafc"> - Simply restart the server and visit http://localhost:3000/pro. It will give 404. After this change it would work ## Mandatory Tasks - [x] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.
This commit is contained in:
1 parent
79944dfed1
commit
c2996cd2f8
3 files changed
+18
-1
No files matched your search
@@ -5,6 +5,10 @@ import { ALLOWED_HOSTNAMES, RESERVED_SUBDOMAINS, WEBAPP_URL } from "@calcom/lib/
|
||||
* @param hostname
|
||||
*/
|
||||
export function getOrgSlug(hostname: string) {
|
||||
if (!hostname.includes(".")) {
|
||||
// A no-dot domain can never be org domain. It automatically handles localhost
|
||||
return null;
|
||||
}
|
||||
// Find which hostname is being currently used
|
||||
const currentHostname = ALLOWED_HOSTNAMES.find((ahn) => {
|
||||
const url = new URL(WEBAPP_URL);
|
||||
|
||||
@@ -30,6 +30,14 @@ describe("Org Domains Utils", () => {
|
||||
isValidOrgDomain: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("should return a non valid org domain for localhost", () => {
|
||||
setupEnvs();
|
||||
expect(orgDomainConfig("localhost:3000")).toEqual({
|
||||
currentOrgDomain: null,
|
||||
isValidOrgDomain: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("getOrgSlug", () => {
|
||||
|
||||
Reference in new issue
Block a user