Skip to content

Commit 5bf915e

Browse files
committed
Fix metabase origin detection logic
1 parent 321f620 commit 5bf915e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

extension/src/content/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,16 @@ async function _init(localConfigs: Promise<object>) {
4444
setupStyles('content.styles.css')
4545
// setupStyles(configs.WEB_CSS_CONFIG_URL, false)
4646

47-
const origin = window.location.origin
47+
let origin = window.location.origin
48+
try {
49+
const MetabaseBootstrap = JSON.parse(document.getElementById("_metabaseBootstrap").textContent)
50+
const siteUrl = MetabaseBootstrap['site-url']
51+
if (siteUrl && !isEmpty(siteUrl)) {
52+
origin = siteUrl
53+
}
54+
} catch (e) {
55+
console.warn('[minusx] MetabaseBootstrap not found, using window location origin')
56+
}
4857
const href = window.location.href
4958
const width = '350'
5059
const variant = 'default'

0 commit comments

Comments
 (0)