From f1524d178fdfeb01d2bd0180008a5edc8e121402 Mon Sep 17 00:00:00 2001 From: Philip Gouverneur Date: Tue, 10 Feb 2026 21:27:06 +0100 Subject: [PATCH 1/2] Fix public uploads in nextcloud instances with subdirectory Signed-off-by: Philip Gouverneur --- src/components/upload/PublicUploadHandler.vue | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/components/upload/PublicUploadHandler.vue b/src/components/upload/PublicUploadHandler.vue index 25796fef5..be81deecc 100644 --- a/src/components/upload/PublicUploadHandler.vue +++ b/src/components/upload/PublicUploadHandler.vue @@ -39,6 +39,14 @@ export default defineComponent({ canUpload(): boolean { return this.routeIsPublic && this.initstate.allow_upload === true; }, + + /** + * Get the base URL including any subdirectory where Nextcloud is installed + */ + baseUrl(): string { + const webroot = (window as any).OC?.webroot || ''; + return window.location.origin + webroot; + }, }, methods: { @@ -76,7 +84,7 @@ export default defineComponent({ try { const token = this.$route.params.token; const uploadPath = this.getCurrentPath(); - const publicDavPath = `${window.location.origin}/public.php/dav/files/${token}${uploadPath}`; + const publicDavPath = `${this.baseUrl}/public.php/dav/files/${token}${uploadPath}`; const client = createClient(publicDavPath); const contents = (await client.getDirectoryContents('/', { details: false })) as Array; @@ -125,12 +133,25 @@ export default defineComponent({ // Setup WebDAV destination const token = this.$route.params.token as string; - const remoteURL = `${window.location.origin}/public.php/dav`; + const currentPath = this.getCurrentPath(); + + // Build the absolute URL properly + const protocol = window.location.protocol; + const host = window.location.host; + const webroot = (window as any).OC?.webroot || ''; + + // Construct the full URL ensuring it's absolute + const baseURL = `${protocol}//${host}${webroot}`; + const davPath = '/public.php/dav'; const rootPath = `/files/${token}`; + const fullPath = `${rootPath}${currentPath}`; + + // The source must be a complete URL + const folderSource = `${baseURL}${davPath}${fullPath}`; const destination = new Folder({ id: 0, - source: remoteURL + rootPath + this.getCurrentPath(), + source: folderSource, root: rootPath, owner: null, permissions: Permission.CREATE, From 6b3b6c23387d44811d3f210be526aedf7b948935 Mon Sep 17 00:00:00 2001 From: Philip Gouverneur Date: Tue, 10 Feb 2026 21:44:13 +0100 Subject: [PATCH 2/2] Apply 'prettier' Signed-off-by: Philip Gouverneur --- src/components/upload/PublicUploadHandler.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/upload/PublicUploadHandler.vue b/src/components/upload/PublicUploadHandler.vue index be81deecc..f7a136b94 100644 --- a/src/components/upload/PublicUploadHandler.vue +++ b/src/components/upload/PublicUploadHandler.vue @@ -139,13 +139,13 @@ export default defineComponent({ const protocol = window.location.protocol; const host = window.location.host; const webroot = (window as any).OC?.webroot || ''; - + // Construct the full URL ensuring it's absolute const baseURL = `${protocol}//${host}${webroot}`; const davPath = '/public.php/dav'; const rootPath = `/files/${token}`; const fullPath = `${rootPath}${currentPath}`; - + // The source must be a complete URL const folderSource = `${baseURL}${davPath}${fullPath}`;