Refactor cookie handling in Index and update API call in Schedule for improved error logging and response handling

This commit is contained in:
2025-07-28 13:08:18 +02:00
parent f98ffef4ce
commit dd6627ae35
2 changed files with 35 additions and 32 deletions

View File

@@ -56,7 +56,19 @@ export default function Index() {
}
);
const cookie = response.headers['set-cookie']?.join('; ') || '';
const cookieArray = response.headers['set-cookie'] as string | string[] | undefined;
let cookie = '';
if (Array.isArray(cookieArray)) {
const lastAuth = cookieArray.reverse().find(c => c.startsWith('.ASPXAUTH='));
if (lastAuth) {
cookie = lastAuth.split(';')[0];
}
} else if (typeof cookieArray === 'string' && cookieArray.startsWith('.ASPXAUTH=')) {
cookie = cookieArray.split(';')[0];
}
console.log('Set-Cookie:', cookieArray);
console.log('cookie:', cookie);
const userId = response.data.Data.UserID;
const fullName = response.data.Data.FullName;