The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Dynamic embed host
Steven Tey7e8bc738da49
diff --git a/packages/embeds/core/src/constants.ts b/packages/embeds/core/src/constants.tsindex 745e5690e2..d3410a9d03 100644--- a/packages/embeds/core/src/constants.ts+++ b/packages/embeds/core/src/constants.ts@@ -1,2 +1 @@-export const EMBED_REFERRALS_URL = "https://app.dub.co/embed/referrals";export const DUB_CONTAINER_ID = "dub-embed-container";diff --git a/packages/embeds/core/src/core.ts b/packages/embeds/core/src/core.tsindex eff4427a3c..4cb726e813 100644--- a/packages/embeds/core/src/core.ts+++ b/packages/embeds/core/src/core.ts@@ -1,4 +1,4 @@-import { DUB_CONTAINER_ID, EMBED_REFERRALS_URL } from "./constants";+import { DUB_CONTAINER_ID } from "./constants";import { EmbedError } from "./error";import { DubEmbedOptions, DubInitResult, IframeMessage } from "./types";@@ -45,7 +45,16 @@ class DubEmbed {...containerStyles,});- const iframeUrl = data === "referrals" ? EMBED_REFERRALS_URL : "";+ const host = window.location.hostname;+ const embedUrlHost =+ host === "localhost"+ ? "http://localhost:8888"+ : host === "preview.dub.co"+ ? "https://preview.dub.co"+ : "https://app.dub.co";++ const iframeUrl =+ data === "referrals" ? `${embedUrlHost}/embed/referrals` : "";if (!iframeUrl) {console.error("[Dub] Invalid embed data type.");