carnet panel2

This commit is contained in:
alma 2025-04-20 16:50:11 +02:00
parent 09089090a5
commit d19c0ef34d

View File

@ -44,15 +44,19 @@ export async function GET(request: Request) {
// Remove trailing slash if present // Remove trailing slash if present
const normalizedBaseURL = baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL; 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({ const client = createClient({
username: credentials.username, username: credentials.username,
password: credentials.password, password: credentials.password,
baseURL: normalizedBaseURL, baseURL: webdavURL,
authType: 'basic', authType: 'basic',
}); });
// Construct the folder path // Construct the folder path
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 { try {
@ -73,10 +77,18 @@ export async function GET(request: Request) {
return NextResponse.json(markdownFiles); return NextResponse.json(markdownFiles);
} catch (error) { } catch (error) {
console.error('Error listing directory contents:', 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 }); 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);
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 }); return NextResponse.json({ error: 'Failed to fetch files' }, { status: 500 });
} }
} }