diff --git a/build-scripts/bundle.cjs b/build-scripts/bundle.cjs index 3a3c6929b8..ef59a29631 100644 --- a/build-scripts/bundle.cjs +++ b/build-scripts/bundle.cjs @@ -55,7 +55,7 @@ module.exports.definedVars = ({ isProdBuild, latestBuild, defineOverlay }) => ({ __STATIC_PATH__: "/static/", __HASS_URL__: `\`${ "HASS_URL" in process.env - ? process.env["HASS_URL"] + ? process.env.HASS_URL : "${location.protocol}//${location.host}" }\``, "process.env.NODE_ENV": JSON.stringify( diff --git a/build-scripts/gulp/entry-html.js b/build-scripts/gulp/entry-html.js index 016aab28c2..b5994b4d68 100644 --- a/build-scripts/gulp/entry-html.js +++ b/build-scripts/gulp/entry-html.js @@ -56,6 +56,7 @@ const getCommonTemplateVars = () => { ); return { modernRegex: compileRegex(browserRegexes.concat(haMacOSRegex)).toString(), + hassUrl: process.env.HASS_URL || "", }; }; diff --git a/src/components/ha-hls-player.ts b/src/components/ha-hls-player.ts index c9ac9e1571..64ba51706e 100644 --- a/src/components/ha-hls-player.ts +++ b/src/components/ha-hls-player.ts @@ -123,7 +123,7 @@ class HaHLSPlayer extends LitElement { try { const { url } = await fetchStreamUrl(this.hass!, this.entityid); - this._url = url; + this._url = this.hass.hassUrl(url); this._cleanUp(); this._resetError(); this._startHls(); @@ -181,15 +181,7 @@ class HaHLSPlayer extends LitElement { let playlist_url: string; if (match !== null && matchTwice === null) { // Only send the regular playlist url if we match exactly once - // In case we arrive here with a relative URL, we need to provide a valid - // base/absolute URL to avoid the URL() constructor throwing an error. - let base_url: string; - try { - base_url = new URL(this._url).href; - } catch (_error) { - base_url = new URL(this._url, window.location.href).href; - } - playlist_url = new URL(match[3], base_url).href; + playlist_url = new URL(match[3], this._url).href; } else { playlist_url = this._url; } @@ -219,7 +211,7 @@ class HaHLSPlayer extends LitElement { await this.hass!.auth.external!.fireMessage({ type: "exoplayer/play_hls", payload: { - url: new URL(url, window.location.href).toString(), + url, muted: this.muted, }, }); diff --git a/src/components/ha-picture-upload.ts b/src/components/ha-picture-upload.ts index 414236e262..ade3d9fa0f 100644 --- a/src/components/ha-picture-upload.ts +++ b/src/components/ha-picture-upload.ts @@ -198,7 +198,7 @@ export class HaPictureUpload extends LitElement { const url = generateImageThumbnailUrl(mediaId, undefined, true); let data; try { - data = await getImageData(url); + data = await getImageData(this.hass, url); } catch (err: any) { showAlertDialog(this, { text: err.toString(), diff --git a/src/components/user/ha-person-badge.ts b/src/components/user/ha-person-badge.ts index 675166c962..8b5078b2c1 100644 --- a/src/components/user/ha-person-badge.ts +++ b/src/components/user/ha-person-badge.ts @@ -4,9 +4,12 @@ import { classMap } from "lit/directives/class-map"; import { styleMap } from "lit/directives/style-map"; import type { BasePerson } from "../../data/person"; import { computeUserInitials } from "../../data/user"; +import type { HomeAssistant } from "../../types"; @customElement("ha-person-badge") class PersonBadge extends LitElement { + @property({ attribute: false }) public hass!: HomeAssistant; + @property({ attribute: false }) public person?: BasePerson; protected render() { @@ -18,7 +21,9 @@ class PersonBadge extends LitElement { if (picture) { return html`
`; } diff --git a/src/components/user/ha-user-badge.ts b/src/components/user/ha-user-badge.ts index 421f65468b..df1520d60b 100644 --- a/src/components/user/ha-user-badge.ts +++ b/src/components/user/ha-user-badge.ts @@ -50,7 +50,9 @@ class UserBadge extends LitElement { if (picture) { return html``; } diff --git a/src/data/backup_onboarding.ts b/src/data/backup_onboarding.ts index bca3253679..80c37126bb 100644 --- a/src/data/backup_onboarding.ts +++ b/src/data/backup_onboarding.ts @@ -22,7 +22,7 @@ export interface BackupOnboardingConfig extends BackupOnboardingInfo { export const fetchBackupOnboardingInfo = async () => handleFetchPromise