feat: integrate FlareSolverr for Cloudflare bypass on clone sources
- Add FLARESOLVERR_URL env var to .env.example - Update fetchSourceFurnidata to fall back to FlareSolverr on CF challenges (403/HTML) - Add docker-compose.yml with FlareSolverr service - Add scripts/health-check.sh for FlareSolverr readiness check - Add health:check script to package.json - Document FlareSolverr setup in README
This commit is contained in:
1 parent
2e87e5bf09
commit
3edc987281
7 files changed
+125
-6
No files matched your search
@@ -5,6 +5,7 @@ import { db, ItemsBase } from "@/lib/db";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { extractFurniIconPng } from "@/lib/services/clone-icon";
|
||||
import type { CloneSource } from "@/lib/services/clone-sources";
|
||||
import { fetchWithFlareSolver } from "@/lib/services/flare-solver";
|
||||
import { getFurniAssetDirs } from "@/lib/services/furni-asset-dirs";
|
||||
import { appendFurniEntry } from "@/lib/services/furni-data";
|
||||
import {
|
||||
@@ -88,14 +89,26 @@ export async function fetchSourceFurnidata(
|
||||
): Promise<SourceFurni[]> {
|
||||
const hit = cache.get(url);
|
||||
if (hit && now && now - hit.ts < TTL) return hit.list;
|
||||
const res = await fetch(url, {
|
||||
signal: AbortSignal.timeout(30000),
|
||||
headers: browserHeaders(),
|
||||
});
|
||||
if (!res.ok) throw new Error(`furnidata fetch failed: ${res.status} ${url}`);
|
||||
let body: string;
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
signal: AbortSignal.timeout(30000),
|
||||
headers: browserHeaders(),
|
||||
});
|
||||
if (
|
||||
res.ok &&
|
||||
res.headers.get("content-type")?.includes("application/json")
|
||||
) {
|
||||
body = await res.text();
|
||||
} else {
|
||||
body = await fetchWithFlareSolver(url);
|
||||
}
|
||||
} catch {
|
||||
body = await fetchWithFlareSolver(url);
|
||||
}
|
||||
let list: SourceFurni[];
|
||||
try {
|
||||
const json = await res.json();
|
||||
const json = JSON.parse(body);
|
||||
list = parseFurnidata(json);
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
|
||||
Reference in new issue
Block a user