diff --git a/.env.example b/.env.example index dae85a0ed9..cebebfa0d4 100644 --- a/.env.example +++ b/.env.example @@ -25,6 +25,7 @@ NEXT_PUBLIC_LICENSE_CONSENT='' NEXT_PUBLIC_WEBAPP_URL='http://localhost:3000' # Change to 'http://localhost:3001' if running the website simultaneously NEXT_PUBLIC_WEBSITE_URL='http://localhost:3000' +NEXT_PUBLIC_EMBED_LIB_URL='http://localhost:3000/embed/embed.js' # To enable SAML login, set both these variables # @see https://github.com/calcom/cal.com/tree/main/packages/ee#setting-up-saml-login diff --git a/apps/web/.gitignore b/apps/web/.gitignore index abc84320a8..46f3800f7b 100644 --- a/apps/web/.gitignore +++ b/apps/web/.gitignore @@ -61,3 +61,6 @@ yarn-error.log* # Typescript tsconfig.tsbuildinfo + +# Autogenerated embed content +public/embed diff --git a/apps/web/components/Embed.tsx b/apps/web/components/Embed.tsx index 31ab4a3991..1885747c18 100644 --- a/apps/web/components/Embed.tsx +++ b/apps/web/components/Embed.tsx @@ -12,6 +12,7 @@ import { Button, Switch } from "@calcom/ui"; import { Dialog, DialogContent, DialogClose } from "@calcom/ui/Dialog"; import { InputLeading, Label, TextArea, TextField } from "@calcom/ui/form/fields"; +import { WEBAPP_URL, EMBED_LIB_URL } from "@lib/config/constants"; import { trpc } from "@lib/trpc"; import NavTabs from "@components/NavTabs"; @@ -216,16 +217,10 @@ const embeds: { ]; function getEmbedSnippetString() { - let embedJsUrl = "https://cal.com/embed.js"; - let isLocal = false; - if (location.hostname === "localhost") { - embedJsUrl = "http://localhost:3100/dist/embed.umd.js"; - isLocal = true; - } // TODO: Import this string from @calcom/embed-snippet return ` -(function (C, A, L) { let p = function (a, ar) { a.q.push(ar); }; let d = C.document; C.Cal = C.Cal || function () { let cal = C.Cal; let ar = arguments; if (!cal.loaded) { cal.ns = {}; cal.q = cal.q || []; d.head.appendChild(d.createElement("script")).src = A; cal.loaded = true; } if (ar[0] === L) { const api = function () { p(api, arguments); }; const namespace = ar[1]; api.q = api.q || []; typeof namespace === "string" ? (cal.ns[namespace] = api) && p(api, ar) : p(cal, ar); return; } p(cal, ar); }; })(window, "${embedJsUrl}", "init"); -Cal("init"${isLocal ? ', {origin:"http://localhost:3000/"}' : ""}); +(function (C, A, L) { let p = function (a, ar) { a.q.push(ar); }; let d = C.document; C.Cal = C.Cal || function () { let cal = C.Cal; let ar = arguments; if (!cal.loaded) { cal.ns = {}; cal.q = cal.q || []; d.head.appendChild(d.createElement("script")).src = A; cal.loaded = true; } if (ar[0] === L) { const api = function () { p(api, arguments); }; const namespace = ar[1]; api.q = api.q || []; typeof namespace === "string" ? (cal.ns[namespace] = api) && p(api, ar) : p(cal, ar); return; } p(cal, ar); }; })(window, "${EMBED_LIB_URL}", "init"); +Cal("init", {origin:"${WEBAPP_URL}"}); `; } @@ -815,7 +810,7 @@ ${getEmbedTypeSpecificString().trim()} className="border-1 h-[75vh] border" width="100%" height="100%" - src={`http://localhost:3100/preview.html?embedType=${embedType}&calLink=${calLink}`} + src={`${WEBAPP_URL}/embed/preview.html?embedType=${embedType}&calLink=${calLink}`} /> diff --git a/packages/embeds/embed-core/index.html b/packages/embeds/embed-core/index.html index 016f88a672..cf631379f0 100644 --- a/packages/embeds/embed-core/index.html +++ b/packages/embeds/embed-core/index.html @@ -44,7 +44,7 @@ } p(cal, ar); }; - })(window, "//localhost:3100/dist/embed.umd.js", "init"); + })(window, "//localhost:3000/embed/embed.js", "init"); - -
- -