add cathes to middleware

This commit is contained in:
Kentai Radiquum 2025-03-16 02:55:18 +05:00
parent 38faa451c3
commit 28c203114b
Signed by: Radiquum
GPG key ID: 858E8EE696525EED

View file

@ -60,6 +60,11 @@ export default async function middleware(
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
},
}).catch((err) => {
console.log(err);
return new Response(err.message, {
status: 500,
});
});
const pageData = await page.text();
@ -94,6 +99,11 @@ export default async function middleware(
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
},
}).catch((err) => {
console.log(err);
return new Response(err.message, {
status: 500,
});
});
return new Response(JSON.stringify({ url: `https:${response.headers.get("Location")}`, poster: `https://st.sibnet.ru${posterUrl[0]}` }), {
@ -177,6 +187,11 @@ export default async function middleware(
const response = await fetch(`https://${path}`, {
method: "POST",
body: formData,
}).catch((err) => {
console.log(err);
return new Response(err.message, {
status: 500,
});
});
const data = await response.json();
return new Response(JSON.stringify(data), {