Skip to content

Commit d465079

Browse files
committed
fix(hub-ui): read import.meta.url through a variable so Vite doesn't inline the module
Vite's lib build recognizes the literal `new URL('...', import.meta.url)` asset pattern and was inlining the embedded/standalone entry's own source as a `data:video/mp2t` URL — so at runtime the dock resolved its hub base from that data URL instead of the served script URL, and connection-meta discovery failed. Assigning import.meta.url to a variable first sidesteps the pattern matcher; the base stays the real runtime URL.
1 parent 90930f8 commit d465079

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎packages/hub-ui/src/client/embedded/index.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ async function mountDock(): Promise<void> {
2525
// The hub base is wherever this script was served from: the page origin's
2626
// copy first (the common same-origin mount), the serving origin second
2727
// (a host page on another backend loading the script cross-origin).
28-
const baseUrl = new URL('./', import.meta.url)
28+
//
29+
// Read import.meta.url through a variable: Vite's lib build rewrites the
30+
// literal `new URL('...', import.meta.url)` asset pattern (inlining the
31+
// module as a `data:` URL), which would make the base the data URL instead
32+
// of the runtime script URL.
33+
const moduleUrl = import.meta.url
34+
const baseUrl = new URL('./', moduleUrl)
2935
const rpc = await getDevframeRpcClient({
3036
baseURL: [baseUrl.pathname, baseUrl.href],
3137
// The dock ships its own authorization view; skip devframe's native

‎packages/hub-ui/src/client/standalone/main.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ watchEffect(() => {
2020

2121
async function main(): Promise<void> {
2222
// Served at the hub base with relative assets: `./__connection.json`
23-
// resolves against the page URL first, the module URL second.
23+
// resolves against the page URL first, the module URL second. Read
24+
// import.meta.url through a variable so Vite's build doesn't rewrite the
25+
// literal `new URL('...', import.meta.url)` asset pattern into a data URL.
26+
const moduleUrl = import.meta.url
2427
const rpc = await getDevframeRpcClient({
25-
baseURL: ['./', new URL('./', import.meta.url).href],
28+
baseURL: ['./', new URL('./', moduleUrl).href],
2629
simpleAuth: false,
2730
})
2831

0 commit comments

Comments
 (0)