From dad67c90021805c5d2ff514d436cf953c91414e3 Mon Sep 17 00:00:00 2001 From: alma Date: Sun, 20 Apr 2025 16:40:36 +0200 Subject: [PATCH] carnet panel2 --- app/api/nextcloud/files/route.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/api/nextcloud/files/route.ts b/app/api/nextcloud/files/route.ts index 438220aa..b7277dd4 100644 --- a/app/api/nextcloud/files/route.ts +++ b/app/api/nextcloud/files/route.ts @@ -35,14 +35,19 @@ export async function GET(request: Request) { console.log('Using credentials for user:', credentials.username); console.log('Accessing folder:', folder); - // Initialize WebDAV client + // Initialize WebDAV client with proper URL construction + const baseURL = process.env.NEXTCLOUD_URL; + if (!baseURL) { + throw new Error('NEXTCLOUD_URL environment variable is not set'); + } + const client = createClient({ username: credentials.username, password: credentials.password, - baseURL: process.env.NEXTCLOUD_URL, + baseURL: baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL, }); - const folderPath = `/remote.php/dav/files/${credentials.username}/Private/${folder}`; + const folderPath = `remote.php/dav/files/${credentials.username}/Private/${folder}`; console.log('Full folder path:', folderPath); // List files in the specified folder