From d19c0ef34d88683a6daf3df59bd6d50a713596f7 Mon Sep 17 00:00:00 2001 From: alma Date: Sun, 20 Apr 2025 16:50:11 +0200 Subject: [PATCH] carnet panel2 --- app/api/nextcloud/files/route.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/api/nextcloud/files/route.ts b/app/api/nextcloud/files/route.ts index 181c4218..3b3d2178 100644 --- a/app/api/nextcloud/files/route.ts +++ b/app/api/nextcloud/files/route.ts @@ -44,15 +44,19 @@ export async function GET(request: Request) { // Remove trailing slash if present const normalizedBaseURL = baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL; + // Construct the full WebDAV URL + const webdavURL = `${normalizedBaseURL}/remote.php/dav/files/${credentials.username}/Private`; + console.log('WebDAV URL:', webdavURL); + const client = createClient({ username: credentials.username, password: credentials.password, - baseURL: normalizedBaseURL, + baseURL: webdavURL, authType: 'basic', }); // Construct the folder path - const folderPath = `remote.php/dav/files/${credentials.username}/Private/${folder}`; + const folderPath = folder; console.log('Full folder path:', folderPath); try { @@ -73,10 +77,18 @@ export async function GET(request: Request) { return NextResponse.json(markdownFiles); } catch (error) { console.error('Error listing directory contents:', error); + if (error instanceof Error) { + console.error('Error details:', error.message); + console.error('Error stack:', error.stack); + } return NextResponse.json({ error: 'Failed to list directory contents' }, { status: 500 }); } } catch (error) { console.error('Error fetching files:', error); + if (error instanceof Error) { + console.error('Error details:', error.message); + console.error('Error stack:', error.stack); + } return NextResponse.json({ error: 'Failed to fetch files' }, { status: 500 }); } } \ No newline at end of file