From 78fd6ad08aee2c35d4fe2ab9d140b671773953fa Mon Sep 17 00:00:00 2001 From: Hemant M Mehta Date: Thu, 21 Aug 2025 15:36:46 +0530 Subject: [PATCH 1/4] fix-atoms-in-browser closes: #22661 --- packages/platform/atoms/vite.config.ts | 4 ++++ packages/ui/components/credits/Credits.tsx | 13 +++++++++++-- packages/ui/components/icon/IconSprites.tsx | 21 +++++++++++++-------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/packages/platform/atoms/vite.config.ts b/packages/platform/atoms/vite.config.ts index 975682e09daa43..7a6b6a7333f9ec 100644 --- a/packages/platform/atoms/vite.config.ts +++ b/packages/platform/atoms/vite.config.ts @@ -7,6 +7,8 @@ import dts from "vite-plugin-dts"; export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), ""); // .env inside of packages/platform/atoms const webAppUrl = env.NEXT_PUBLIC_WEBAPP_URL ?? "https://app.cal.com"; + const calcomVersion = env.NEXT_PUBLIC_CALCOM_VERSION ?? ""; + const vercelCommitSha = env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA ?? ""; return { optimizeDeps: { include: [ @@ -22,6 +24,8 @@ export default defineConfig(({ mode }) => { plugins: [react(), dts({ insertTypesEntry: true })], define: { "process.env.NEXT_PUBLIC_WEBAPP_URL": `"${webAppUrl}"`, + "process.env.NEXT_PUBLIC_CALCOM_VERSION": `"${calcomVersion}"`, + "process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA": `"${vercelCommitSha}"`, }, ssr: { noExternal: ["turndown"], // Example if you want to disable SSR for your library diff --git a/packages/ui/components/credits/Credits.tsx b/packages/ui/components/credits/Credits.tsx index fd27cbd371d3eb..53d01e159c6fc2 100644 --- a/packages/ui/components/credits/Credits.tsx +++ b/packages/ui/components/credits/Credits.tsx @@ -1,3 +1,6 @@ +/* eslint-disable prettier/prettier */ + +/* eslint-disable turbo/no-undeclared-env-vars */ "use client"; import Link from "next/link"; @@ -5,8 +8,14 @@ import { useEffect, useState } from "react"; import { CALCOM_VERSION, COMPANY_NAME, IS_CALCOM, IS_SELF_HOSTED } from "@calcom/lib/constants"; -// eslint-disable-next-line turbo/no-undeclared-env-vars -const vercelCommitHash = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA; +/* eslint-disable prettier/prettier */ +/* eslint-disable turbo/no-undeclared-env-vars */ + +// Use globalThis.process?.env or fallback to empty string for browser safety +const vercelCommitHash = + typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + ? process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + : ""; const commitHash = vercelCommitHash ? `-${vercelCommitHash.slice(0, 7)}` : ""; const CalComVersion = `v.${CALCOM_VERSION}-${!IS_SELF_HOSTED ? "h" : "sh"}`; diff --git a/packages/ui/components/icon/IconSprites.tsx b/packages/ui/components/icon/IconSprites.tsx index 0f388bec0319b5..afcb64f6164473 100644 --- a/packages/ui/components/icon/IconSprites.tsx +++ b/packages/ui/components/icon/IconSprites.tsx @@ -1,15 +1,20 @@ +/* eslint-disable turbo/no-undeclared-env-vars */ import SVG from "react-inlinesvg"; -// eslint-disable-next-line turbo/no-undeclared-env-vars -const vercelCommitHash = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA; -const commitHash = vercelCommitHash ? `-${vercelCommitHash.slice(0, 7)}` : ""; +// Use globalThis.process?.env or fallback to empty string for browser safety +const CALCOM_VERSION = + typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_CALCOM_VERSION + ? process.env.NEXT_PUBLIC_CALCOM_VERSION + : ""; +const VERCEL_COMMIT_SHA = + typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + ? process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + : ""; + +const commitHash = VERCEL_COMMIT_SHA ? `-${VERCEL_COMMIT_SHA.slice(0, 7)}` : ""; export function IconSprites() { - return ( - - ); + return ; } export default IconSprites; From 09645f574d5fed2dde47156a6afd7c83678d8e10 Mon Sep 17 00:00:00 2001 From: Hemant M Mehta Date: Thu, 21 Aug 2025 16:36:40 +0530 Subject: [PATCH 2/4] coderabbit suggestion Signed-off-by: Hemant M Mehta --- packages/platform/atoms/vite.config.ts | 6 +++--- packages/ui/components/credits/Credits.tsx | 1 + packages/ui/components/icon/IconSprites.tsx | 8 +++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/platform/atoms/vite.config.ts b/packages/platform/atoms/vite.config.ts index 7a6b6a7333f9ec..37a589b82d027a 100644 --- a/packages/platform/atoms/vite.config.ts +++ b/packages/platform/atoms/vite.config.ts @@ -23,9 +23,9 @@ export default defineConfig(({ mode }) => { }, plugins: [react(), dts({ insertTypesEntry: true })], define: { - "process.env.NEXT_PUBLIC_WEBAPP_URL": `"${webAppUrl}"`, - "process.env.NEXT_PUBLIC_CALCOM_VERSION": `"${calcomVersion}"`, - "process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA": `"${vercelCommitSha}"`, + "process.env.NEXT_PUBLIC_WEBAPP_URL": JSON.stringify(webAppUrl), + "process.env.NEXT_PUBLIC_CALCOM_VERSION": JSON.stringify(calcomVersion), + "process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA": JSON.stringify(vercelCommitSha), }, ssr: { noExternal: ["turndown"], // Example if you want to disable SSR for your library diff --git a/packages/ui/components/credits/Credits.tsx b/packages/ui/components/credits/Credits.tsx index 53d01e159c6fc2..831a500238cd24 100644 --- a/packages/ui/components/credits/Credits.tsx +++ b/packages/ui/components/credits/Credits.tsx @@ -9,6 +9,7 @@ import { useEffect, useState } from "react"; import { CALCOM_VERSION, COMPANY_NAME, IS_CALCOM, IS_SELF_HOSTED } from "@calcom/lib/constants"; /* eslint-disable prettier/prettier */ + /* eslint-disable turbo/no-undeclared-env-vars */ // Use globalThis.process?.env or fallback to empty string for browser safety diff --git a/packages/ui/components/icon/IconSprites.tsx b/packages/ui/components/icon/IconSprites.tsx index afcb64f6164473..c26ec2b1459947 100644 --- a/packages/ui/components/icon/IconSprites.tsx +++ b/packages/ui/components/icon/IconSprites.tsx @@ -14,7 +14,13 @@ const VERCEL_COMMIT_SHA = const commitHash = VERCEL_COMMIT_SHA ? `-${VERCEL_COMMIT_SHA.slice(0, 7)}` : ""; export function IconSprites() { - return ; + const WEBAPP_URL = + (typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_WEBAPP_URL) || ""; + // Build URL robustly, avoid double slashes, and default to same-origin when WEBAPP_URL is unset. + const base = WEBAPP_URL.replace(/\/+$/, ""); + const path = "/icons/sprite.svg"; + const src = `${base}${path}?v=${CALCOM_VERSION}${commitHash}`.replace(/([^:]\/)\/+/g, "$1"); + return ; } export default IconSprites; From d09d5e5032ed3f376a22fb960c4ad870f42cf585 Mon Sep 17 00:00:00 2001 From: Hemant M Mehta Date: Thu, 21 Aug 2025 16:52:58 +0530 Subject: [PATCH 3/4] coderabbit suggestion Signed-off-by: Hemant M Mehta --- packages/ui/components/credits/Credits.tsx | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/ui/components/credits/Credits.tsx b/packages/ui/components/credits/Credits.tsx index 831a500238cd24..54861ac9bafe04 100644 --- a/packages/ui/components/credits/Credits.tsx +++ b/packages/ui/components/credits/Credits.tsx @@ -1,6 +1,6 @@ -/* eslint-disable prettier/prettier */ - /* eslint-disable turbo/no-undeclared-env-vars */ + +/* eslint-disable prettier/prettier */ "use client"; import Link from "next/link"; @@ -8,17 +8,17 @@ import { useEffect, useState } from "react"; import { CALCOM_VERSION, COMPANY_NAME, IS_CALCOM, IS_SELF_HOSTED } from "@calcom/lib/constants"; -/* eslint-disable prettier/prettier */ - /* eslint-disable turbo/no-undeclared-env-vars */ +/* eslint-disable prettier/prettier */ // Use globalThis.process?.env or fallback to empty string for browser safety +/* eslint-disable-next-line turbo/no-undeclared-env-vars */ const vercelCommitHash = typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA ? process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA : ""; const commitHash = vercelCommitHash ? `-${vercelCommitHash.slice(0, 7)}` : ""; -const CalComVersion = `v.${CALCOM_VERSION}-${!IS_SELF_HOSTED ? "h" : "sh"}`; +const CalComVersion = `v.${CALCOM_VERSION || "dev"}-${!IS_SELF_HOSTED ? "h" : "sh"}`; export default function Credits() { const [hasMounted, setHasMounted] = useState(false); @@ -30,18 +30,27 @@ export default function Credits() { return ( © {new Date().getFullYear()}{" "} - + {COMPANY_NAME} {" "} {hasMounted && ( <> - + {CalComVersion} {vercelCommitHash && IS_CALCOM ? ( {commitHash} From 4f6f2d7a00db19559966c03748898d12db842a83 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 15 Jan 2026 22:21:25 +0000 Subject: [PATCH 4/4] fix: resolve duplicate keys in vite.config.ts define object - Add back vercelCommitSha variable that was accidentally removed - Remove duplicate template literal entries, keeping only JSON.stringify() versions - Use JSON.stringify() for NODE_ENV for consistency Co-authored-by: hemantmm Co-Authored-By: unknown <> --- packages/platform/atoms/vite.config.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/platform/atoms/vite.config.ts b/packages/platform/atoms/vite.config.ts index 368d71060eee05..3e16f3c72fc04f 100644 --- a/packages/platform/atoms/vite.config.ts +++ b/packages/platform/atoms/vite.config.ts @@ -3,11 +3,13 @@ import path from "path"; import { resolve } from "path"; import { defineConfig, loadEnv } from "vite"; import dts from "vite-plugin-dts"; +import process from "node:process"; export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), ""); // .env inside of packages/platform/atoms const webAppUrl = env.NEXT_PUBLIC_WEBAPP_URL ?? "https://app.cal.com"; const calcomVersion = env.NEXT_PUBLIC_CALCOM_VERSION ?? ""; + const vercelCommitSha = env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA ?? ""; return { optimizeDeps: { include: [ @@ -41,14 +43,11 @@ export default defineConfig(({ mode }) => { "process.env.NEXT_PUBLIC_WEBAPP_URL": JSON.stringify(webAppUrl), "process.env.NEXT_PUBLIC_CALCOM_VERSION": JSON.stringify(calcomVersion), "process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA": JSON.stringify(vercelCommitSha), - "process.env.NEXT_PUBLIC_WEBAPP_URL": `"${webAppUrl}"`, - "process.env.NEXT_PUBLIC_CALCOM_VERSION": `"${calcomVersion}"`, - "process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA": `"${vercelCommitSha}"`, - "process.env.NODE_ENV": `"${mode}"`, + "process.env.NODE_ENV": JSON.stringify(mode), "process.env.__NEXT_ROUTER_BASEPATH": `""`, - "process.env.__NEXT_I18N_SUPPORT": `false`, - "process.env.__NEXT_MANUAL_TRAILING_SLASH": `false`, - "process.env.__NEXT_TRAILING_SLASH": `false`, + "process.env.__NEXT_I18N_SUPPORT": "false", + "process.env.__NEXT_MANUAL_TRAILING_SLASH": "false", + "process.env.__NEXT_TRAILING_SLASH": "false", "process.env": "{}", }, ssr: {