Skip to content

Commit 4a82224

Browse files
roymilohclaude
andcommitted
Generalize popup auth to trigger inside any iframe, not just specific domains
Replace domain regex check with iframe detection (window !== window.parent) so popup-based OAuth works in any embedded context. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4a3a83b commit 4a82224

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/modules/auth.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ import {
77
ResetPasswordParams,
88
} from "./auth.types";
99

10-
const POPUP_AUTH_DOMAIN_REGEX =
11-
/^(preview-sandbox--|preview--|checkpoint--)[^.]+\./;
12-
13-
function isPopupAuthDomain(): boolean {
10+
function isInsideIframe(): boolean {
1411
if (typeof window === "undefined") return false;
15-
return POPUP_AUTH_DOMAIN_REGEX.test(window.location.hostname);
12+
return window !== window.parent;
1613
}
1714

1815
/**
@@ -147,9 +144,9 @@ export function createAuthModule(
147144

148145
const loginUrl = `${options.appBaseUrl}/api${authPath}?${queryParams}`;
149146

150-
// On preview/sandbox/checkpoint domains the app runs inside an iframe —
151-
// use a popup to avoid OAuth providers blocking iframe navigation.
152-
if (isPopupAuthDomain()) {
147+
// When running inside an iframe, use a popup to avoid OAuth providers
148+
// blocking iframe navigation.
149+
if (isInsideIframe()) {
153150
const popupLoginUrl = `${loginUrl}&popup_origin=${encodeURIComponent(window.location.origin)}`;
154151
return loginViaPopup(popupLoginUrl, redirectUrl, window.location.origin);
155152
}

0 commit comments

Comments
 (0)