From cb44e8572f502b0f1d072bfd19304eaef526d37f Mon Sep 17 00:00:00 2001
From: David Valdez <valdez.dj@gmail.com>
Date: Tue, 25 Apr 2023 02:20:29 +0000
Subject: [PATCH 1/5] Changes to support custom basepath in routing

---
 ui/public/manifest.json | 6 +++---
 ui/src/index.tsx        | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ui/public/manifest.json b/ui/public/manifest.json
index 36ff4e9..dc8ab48 100644
--- a/ui/public/manifest.json
+++ b/ui/public/manifest.json
@@ -8,15 +8,15 @@
   "background_color": "white",
   "icons": [
     {
-      "src": "/assets/logo192.png",
+      "src": "/photoview/logo192.png",
       "sizes": "192x192"
     },
     {
-      "src": "/assets/logo512.png",
+      "src": "/photoview/logo512.png",
       "sizes": "512x512"
     },
     {
-      "src": "/assets/photoview-logo.svg",
+      "src": "/photoview/photoview-logo.svg",
       "sizes": "150x150"
     }
   ]
diff --git a/ui/src/index.tsx b/ui/src/index.tsx
index 3c0d73f..072b14e 100644
--- a/ui/src/index.tsx
+++ b/ui/src/index.tsx
@@ -16,7 +16,7 @@ setupLocalization()
 
 const Main = () => (
   <ApolloProvider client={client}>
-    <Router>
+    <Router basename={import.meta.env.BASE_URL}>
       <SidebarProvider>
         <App />
       </SidebarProvider>

From 31f1810e5e65ee23f2a761aaffb8cec2b69bc5e7 Mon Sep 17 00:00:00 2001
From: David Valdez <valdez.dj@gmail.com>
Date: Wed, 26 Apr 2023 04:41:08 +0000
Subject: [PATCH 2/5] Add support for custom base path to URL generator

---
 ui/src/components/photoGallery/ProtectedMedia.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/src/components/photoGallery/ProtectedMedia.tsx b/ui/src/components/photoGallery/ProtectedMedia.tsx
index 305f16d..326217d 100644
--- a/ui/src/components/photoGallery/ProtectedMedia.tsx
+++ b/ui/src/components/photoGallery/ProtectedMedia.tsx
@@ -13,7 +13,7 @@ const placeholder =
 const getProtectedUrl = (url?: string) => {
   if (url == undefined) return undefined
 
-  const imgUrl = new URL(url, location.origin)
+  const imgUrl = new URL(`${import.meta.env.BASE_URL}/${url}`, location.origin)
 
   const tokenRegex = location.pathname.match(/^\/share\/([\d\w]+)(\/?.*)$/)
   if (tokenRegex) {

From d8bb69bbba2f8bd7c68c0b6d0c215b8cf217949b Mon Sep 17 00:00:00 2001
From: David Valdez <valdez.dj@gmail.com>
Date: Sat, 29 Apr 2023 20:36:07 -0500
Subject: [PATCH 3/5] Remove hardcoded basepath

---
 ui/public/manifest.json | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ui/public/manifest.json b/ui/public/manifest.json
index dc8ab48..36ff4e9 100644
--- a/ui/public/manifest.json
+++ b/ui/public/manifest.json
@@ -8,15 +8,15 @@
   "background_color": "white",
   "icons": [
     {
-      "src": "/photoview/logo192.png",
+      "src": "/assets/logo192.png",
       "sizes": "192x192"
     },
     {
-      "src": "/photoview/logo512.png",
+      "src": "/assets/logo512.png",
       "sizes": "512x512"
     },
     {
-      "src": "/photoview/photoview-logo.svg",
+      "src": "/assets/photoview-logo.svg",
       "sizes": "150x150"
     }
   ]

From 170f1ac59c33b9530be55c8ff2cc41e2d382f6b0 Mon Sep 17 00:00:00 2001
From: David Valdez <valdez.dj@gmail.com>
Date: Sun, 30 Apr 2023 01:37:36 +0000
Subject: [PATCH 4/5] Fix for login URL

---
 ui/src/Pages/LoginPage/loginUtilities.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/src/Pages/LoginPage/loginUtilities.tsx b/ui/src/Pages/LoginPage/loginUtilities.tsx
index 4f75403..5b53b3b 100644
--- a/ui/src/Pages/LoginPage/loginUtilities.tsx
+++ b/ui/src/Pages/LoginPage/loginUtilities.tsx
@@ -12,7 +12,7 @@ export const INITIAL_SETUP_QUERY = gql`
 
 export function login(token: string) {
   saveTokenCookie(token)
-  window.location.href = '/'
+  window.location.href = `${import.meta.env.BASE_URL}`
 }
 
 export const Container = styled.div.attrs({ className: 'mt-20' })``

From efda44a20b3713ba0fc2d324cc92cbbaa8a32ee6 Mon Sep 17 00:00:00 2001
From: David Valdez <valdez.dj@gmail.com>
Date: Sun, 30 Apr 2023 17:17:59 -0500
Subject: [PATCH 5/5] Fix case of double slash

---
 ui/src/components/photoGallery/ProtectedMedia.tsx | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ui/src/components/photoGallery/ProtectedMedia.tsx b/ui/src/components/photoGallery/ProtectedMedia.tsx
index 326217d..5b50bdd 100644
--- a/ui/src/components/photoGallery/ProtectedMedia.tsx
+++ b/ui/src/components/photoGallery/ProtectedMedia.tsx
@@ -13,7 +13,10 @@ const placeholder =
 const getProtectedUrl = (url?: string) => {
   if (url == undefined) return undefined
 
-  const imgUrl = new URL(`${import.meta.env.BASE_URL}/${url}`, location.origin)
+  const imgUrl = new URL(
+    `${import.meta.env.BASE_URL}${url}`.replace(/\/\//g, '/'),
+    location.origin
+  )
 
   const tokenRegex = location.pathname.match(/^\/share\/([\d\w]+)(\/?.*)$/)
   if (tokenRegex) {
