From 048e0cc67b5bd29f92abe8b4de3595cd39f095cd Mon Sep 17 00:00:00 2001 From: David Valdez Date: Sun, 3 Sep 2023 18:29:18 -0500 Subject: [PATCH] Fix download path on custom base path --- .../components/sidebar/SidebarDownloadMedia.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ui/src/components/sidebar/SidebarDownloadMedia.tsx b/ui/src/components/sidebar/SidebarDownloadMedia.tsx index 19bba3a7..d489df25 100644 --- a/ui/src/components/sidebar/SidebarDownloadMedia.tsx +++ b/ui/src/components/sidebar/SidebarDownloadMedia.tsx @@ -1,18 +1,18 @@ -import React from 'react' -import { MessageState } from '../messages/Messages' -import { useLazyQuery, gql } from '@apollo/client' -import { authToken } from '../../helpers/authentication' +import { gql, useLazyQuery } from '@apollo/client' import { useTranslation } from 'react-i18next' +import { NotificationType } from '../../__generated__/globalTypes' +import { authToken } from '../../helpers/authentication' import { TranslationFn } from '../../localization' +import { MessageState } from '../messages/Messages' import { MediaSidebarMedia } from './MediaSidebar/MediaSidebar' +import React from 'react' +import { SidebarSection, SidebarSectionTitle } from './SidebarComponents' import SidebarTable from './SidebarTable' import { sidebarDownloadQuery, sidebarDownloadQueryVariables, sidebarDownloadQuery_media_downloads, } from './__generated__/sidebarDownloadQuery' -import { SidebarSection, SidebarSectionTitle } from './SidebarComponents' -import { NotificationType } from '../../__generated__/globalTypes' export const SIDEBAR_DOWNLOAD_QUERY = gql` query sidebarDownloadQuery($mediaId: ID!) { @@ -56,7 +56,10 @@ const formatBytes = (t: TranslationFn) => (bytes: number) => { } const downloadMedia = (t: TranslationFn) => async (url: string) => { - const imgUrl = new URL(url, location.origin) + const imgUrl = new URL( + `${import.meta.env.BASE_URL}${url}`.replace(/\/\//g, '/'), + location.origin + ) if (authToken() == null) { // Get share token if not authorized