carnet panel2

This commit is contained in:
alma 2025-04-20 16:47:15 +02:00
parent e64a54c929
commit 947d3f048f

View File

@ -47,13 +47,15 @@ export async function GET(request: Request) {
const client = createClient({ const client = createClient({
username: credentials.username, username: credentials.username,
password: credentials.password, password: credentials.password,
baseURL: normalizedBaseURL, baseURL: `${normalizedBaseURL}/remote.php/dav/files/${credentials.username}/Private`,
authType: 'basic',
}); });
// Construct the folder path with leading slash // Construct the folder path without leading slash
const folderPath = `/remote.php/dav/files/${credentials.username}/Private/${folder}`; const folderPath = folder;
console.log('Full folder path:', folderPath); console.log('Full folder path:', folderPath);
try {
// List files in the specified folder // List files in the specified folder
const files = await client.getDirectoryContents(folderPath); const files = await client.getDirectoryContents(folderPath);
console.log('Found files:', files.length); console.log('Found files:', files.length);
@ -69,6 +71,10 @@ export async function GET(request: Request) {
})); }));
return NextResponse.json(markdownFiles); return NextResponse.json(markdownFiles);
} catch (error) {
console.error('Error listing directory contents:', error);
return NextResponse.json({ error: 'Failed to list directory contents' }, { status: 500 });
}
} catch (error) { } catch (error) {
console.error('Error fetching files:', error); console.error('Error fetching files:', error);
return NextResponse.json({ error: 'Failed to fetch files' }, { status: 500 }); return NextResponse.json({ error: 'Failed to fetch files' }, { status: 500 });