diff --git a/app/api/nextcloud/files/route.ts b/app/api/nextcloud/files/route.ts index b7277dd4..2ef3f2bc 100644 --- a/app/api/nextcloud/files/route.ts +++ b/app/api/nextcloud/files/route.ts @@ -41,12 +41,16 @@ export async function GET(request: Request) { throw new Error('NEXTCLOUD_URL environment variable is not set'); } + // Ensure baseURL ends with a slash + const normalizedBaseURL = baseURL.endsWith('/') ? baseURL : `${baseURL}/`; + const client = createClient({ username: credentials.username, password: credentials.password, - baseURL: baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL, + baseURL: normalizedBaseURL, }); + // Construct the folder path without leading slash const folderPath = `remote.php/dav/files/${credentials.username}/Private/${folder}`; console.log('Full folder path:', folderPath);