fix: improve error handling for Cloudflare-protected clone sources
- Detect HTML responses from FlareSolverr and throw descriptive error instead of letting JSON.parse fail with cryptic 'Unexpected token' error - Add try/catch to clone/route.ts GET handler to return 502 with clear message instead of Internal Server Error 500 - Add FLARESOLVERR_URL to .env
This commit is contained in:
1 parent
0abcead359
commit
1fd6f7146b
2 files changed
+25
-6
No files matched your search
@@ -106,6 +106,11 @@ export async function fetchSourceFurnidata(
|
||||
} catch {
|
||||
body = await fetchWithFlareSolver(url);
|
||||
}
|
||||
if (body.trimStart().startsWith("<")) {
|
||||
throw new Error(
|
||||
`Source ${url} is behind a Cloudflare challenge that could not be bypassed. Start FlareSolverr and check its logs.`,
|
||||
);
|
||||
}
|
||||
let list: SourceFurni[];
|
||||
try {
|
||||
const json = JSON.parse(body);
|
||||
|
||||
Reference in new issue
Block a user