Add detailed cookie debugging and validation
This commit is contained in:
@@ -30,7 +30,10 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
let tempCookiesFile: string | null = null;
|
||||
|
||||
try {
|
||||
const { url, cookies } = await request.json();
|
||||
const body = await request.json();
|
||||
const { url, cookies } = body;
|
||||
|
||||
console.log(`Request erhalten - URL: ${url}, Cookies vorhanden: ${!!cookies}, Cookie-Länge: ${cookies ? cookies.length : 0}`);
|
||||
|
||||
if (!url || typeof url !== "string") {
|
||||
return new Response(
|
||||
@@ -59,6 +62,10 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
fileContent.length
|
||||
} Zeichen, erste Zeile: ${fileContent.split("\n")[0]}`
|
||||
);
|
||||
// Prüfe ob wichtige Cookies vorhanden sind
|
||||
const hasLoginInfo = fileContent.includes("LOGIN_INFO");
|
||||
const hasSID = fileContent.includes("SID");
|
||||
console.log(`Cookie-Prüfung - LOGIN_INFO: ${hasLoginInfo}, SID: ${hasSID}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
@@ -67,6 +74,8 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
);
|
||||
// Weiter ohne Cookies
|
||||
}
|
||||
} else {
|
||||
console.log("Keine Cookies im Request oder leer");
|
||||
}
|
||||
|
||||
// YouTube URL validieren
|
||||
@@ -361,11 +370,15 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
{ status: 500, headers: { "Content-Type": "application/json" } }
|
||||
);
|
||||
} finally {
|
||||
// Temporäre Cookie-Datei löschen falls vorhanden
|
||||
// Temporäre Cookie-Datei löschen falls vorhanden (nach einer kurzen Verzögerung, damit Debugging möglich ist)
|
||||
if (tempCookiesFile && existsSync(tempCookiesFile)) {
|
||||
await unlink(tempCookiesFile).catch((err) => {
|
||||
// Warte kurz, damit die Datei für Debugging verfügbar bleibt
|
||||
const fileToDelete = tempCookiesFile;
|
||||
setTimeout(async () => {
|
||||
await unlink(fileToDelete).catch((err) => {
|
||||
console.error("Fehler beim Löschen der temporären Cookie-Datei:", err);
|
||||
});
|
||||
}, 5000); // 5 Sekunden Verzögerung
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user