diff --git a/assets/js/js_output/index.js b/assets/js/js_output/index.js index 76cf4cd86..55b4853e3 100644 --- a/assets/js/js_output/index.js +++ b/assets/js/js_output/index.js @@ -42,7 +42,7 @@ export function leaveChannel() { * * * `data-ref` - a unique identifier used as messages scope * - * * `data-assets-base-url` - the URL to resolve all relative paths + * * `data-assets-base-path` - the path to resolve all relative paths * against in the iframe * * * `data-js-path` - a relative path for the initial output-specific @@ -88,10 +88,12 @@ const JSOutput = { const handleChildMessage = (message) => { if (message.type === "ready" && !this.state.childReady) { + const assetsBaseUrl = + window.location.origin + this.props.assetsBasePath; postMessage({ type: "readyReply", token: this.state.childToken, - baseUrl: this.props.assetsBaseUrl, + baseUrl: assetsBaseUrl, jsPath: this.props.jsPath, }); this.state.childReady = true; @@ -261,7 +263,7 @@ const JSOutput = { function getProps(hook) { return { ref: getAttributeOrThrow(hook.el, "data-ref"), - assetsBaseUrl: getAttributeOrThrow(hook.el, "data-assets-base-url"), + assetsBasePath: getAttributeOrThrow(hook.el, "data-assets-base-path"), jsPath: getAttributeOrThrow(hook.el, "data-js-path"), sessionToken: getAttributeOrThrow(hook.el, "data-session-token"), sessionId: getAttributeOrThrow(hook.el, "data-session-id"), diff --git a/lib/livebook_web/live/output/js_component.ex b/lib/livebook_web/live/output/js_component.ex index fb2f7c1a5..ded964417 100644 --- a/lib/livebook_web/live/output/js_component.ex +++ b/lib/livebook_web/live/output/js_component.ex @@ -8,7 +8,7 @@ defmodule LivebookWeb.Output.JSComponent do phx-hook="JSOutput" phx-update="ignore" data-ref={@info.ref} - data-assets-base-url={Routes.session_url(@socket, :show_asset, @session_id, @info.assets.hash, [])} + data-assets-base-path={Routes.session_path(@socket, :show_asset, @session_id, @info.assets.hash, [])} data-js-path={@info.assets.js_path} data-session-token={session_token(@info.pid)} data-session-id={@session_id}>