diff --git a/packages/embed-sdk/demo-my-invoices.html b/packages/embed-sdk/demo-my-invoices.html
index 6f85dfe..c54dcc4 100644
--- a/packages/embed-sdk/demo-my-invoices.html
+++ b/packages/embed-sdk/demo-my-invoices.html
@@ -211,7 +211,7 @@
My Invoices
diff --git a/packages/embed-sdk/demo-profile.html b/packages/embed-sdk/demo-profile.html
index 3962843..5680fb8 100644
--- a/packages/embed-sdk/demo-profile.html
+++ b/packages/embed-sdk/demo-profile.html
@@ -162,7 +162,7 @@ Profile Editor
diff --git a/packages/embed-sdk/src/shared/base-widget.ts b/packages/embed-sdk/src/shared/base-widget.ts
index 0a75706..06e0ecc 100644
--- a/packages/embed-sdk/src/shared/base-widget.ts
+++ b/packages/embed-sdk/src/shared/base-widget.ts
@@ -43,6 +43,18 @@ export abstract class MPNextWidget extends HTMLElement {
return new URL(s.src).origin;
} catch { /* continue */ }
}
+
+ // Fall back to a sibling widget's api-host (handles Vite dev, where the SDK
+ // is a local module import — no "next-embed" script tag — and a widget
+ // without an explicit api-host would otherwise fetch the wrong origin).
+ const sibling = document.querySelector(
+ "next-user-menu, next-add-to-calendar, next-full-calendar, next-profile, next-my-invoices",
+ );
+ if (sibling && sibling !== this) {
+ const host = sibling.getAttribute("api-host");
+ if (host) return host;
+ }
+
return "";
}