carnet api

This commit is contained in:
alma 2025-04-20 13:26:24 +02:00
parent ae5176e90a
commit 20ae56ce49

View File

@ -41,22 +41,37 @@ export async function GET() {
console.log('Requesting WebDAV URL:', webdavUrl);
// Get all cookies from the request
const cookieHeader = cookieStore.getAll()
const allCookies = cookieStore.getAll();
console.log('Available cookies:', allCookies.map(c => ({
name: c.name,
value: c.value.substring(0, 10) + '...', // Log partial value for security
domain: c.domain,
path: c.path,
secure: c.secure,
httpOnly: c.httpOnly,
sameSite: c.sameSite
})));
const cookieHeader = allCookies
.map(cookie => `${cookie.name}=${cookie.value}`)
.join('; ');
console.log('Sending cookie header:', cookieHeader.substring(0, 100) + '...'); // Log partial header
const foldersResponse = await fetch(webdavUrl, {
headers: {
'Cookie': cookieHeader,
'Depth': '1',
'Content-Type': 'application/xml',
},
credentials: 'include', // Important for cookie handling
});
if (!foldersResponse.ok) {
const errorText = await foldersResponse.text();
console.error('Failed to fetch folders. Status:', foldersResponse.status);
console.error('Response:', errorText);
console.error('Response headers:', Object.fromEntries(foldersResponse.headers.entries()));
throw new Error(`Failed to fetch folders: ${errorText}`);
}