fix: stabilize embedded WeKnora detail page
This commit is contained in:
1 parent
11e54550ed
commit
a28ad2140e
3 files changed
+57
No files matched your search
+8
@@ -51,7 +51,15 @@ function collectThemePayload(): DeerFlowThemePayload {
|
||||
function postThemeToFrame(frame: HTMLIFrameElement | null) {
|
||||
if (!frame?.contentWindow) return;
|
||||
const src = frame.getAttribute("src") || "";
|
||||
if (!src) return;
|
||||
const targetOrigin = new URL(src, window.location.href).origin;
|
||||
try {
|
||||
const currentUrl = frame.contentWindow.location.href;
|
||||
if (!currentUrl || currentUrl === "about:blank") return;
|
||||
if (new URL(currentUrl, window.location.href).origin !== targetOrigin) return;
|
||||
} catch {
|
||||
// Reading location throws once the iframe has reached the cross-origin backend.
|
||||
}
|
||||
frame.contentWindow.postMessage(collectThemePayload(), targetOrigin);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user