removed scrapingbee cuse yuh

This commit is contained in:
bootunloader
2026-01-05 23:58:49 +02:00
parent 653fb266e5
commit 905405d0ae
3 changed files with 138 additions and 118 deletions

View File

@@ -17,7 +17,14 @@ import { createTRPCRouter, protectedProcedure } from "../t";
export const apiAuthRouter = createTRPCRouter({
getCaptcha: protectedProcedure.mutation(async () => {
const scrapingbeeApiKey = env.SCRAPINGBEE_API_KEY ?? "";
const scrapeDoApiKey = env.SCRAPEDO_API_KEY ?? "";
if (!scrapeDoApiKey) {
logger.error("[getCaptcha] Scrape.do API key not configured");
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: "Scrape.do API key not configured",
});
}
try {
const uuid = getUUID();
@@ -25,22 +32,17 @@ export const apiAuthRouter = createTRPCRouter({
logger.info(`[getCaptcha] Fetching captcha image for uuid: ${uuid}`);
// Build ScrapingBee API URL with params
const scrapingbeeUrl = new URL("https://app.scrapingbee.com/api/v1");
scrapingbeeUrl.searchParams.set("api_key", scrapingbeeApiKey);
scrapingbeeUrl.searchParams.set("url", targetUrl);
scrapingbeeUrl.searchParams.set("render_js", "false");
scrapingbeeUrl.searchParams.set("block_resources", "false");
const finalUrl = new URL("http://api.scrape.do/");
finalUrl.searchParams.append("url", targetUrl);
finalUrl.searchParams.append("token", scrapeDoApiKey);
const res = await fetch(scrapingbeeUrl.toString());
const res = await fetch(finalUrl.toString());
if (!res.ok || res.status !== 200) {
// Clone response before reading to avoid consuming body
const clonedRes = res.clone();
const errorText = await clonedRes.text().catch(() => "Unknown error");
logger.error(
`[getCaptcha] ScrapingBee error ${res.status}: ${errorText.substring(0, 200)}`,
);
logger.error(`[getCaptcha] Scrape.do error ${res.status}: ${errorText.substring(0, 200)}`);
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: `Failed to fetch captcha image: ${res.status}`,