Skip to content

Add FlareSolverr bypass settings#24

Merged
defnone merged 2 commits into
mainfrom
codex/flaresolverr-bypass
Jun 22, 2026
Merged

Add FlareSolverr bypass settings#24
defnone merged 2 commits into
mainfrom
codex/flaresolverr-bypass

Conversation

@defnone

@defnone defnone commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add FlareSolverr settings for enabling Cloudflare bypass, server URL, timeout, and connection testing.
  • Add FlareSolverr-backed fallback when tracker pages return Cloudflare challenge HTML.
  • Add SQLite migrations and tests for settings, verification route, and tracker fallback behavior.

Rationale

Some tracker topic pages can be blocked by Cloudflare checks. This adds an opt-in browser-solving fallback without slowing down the normal tracker fetch path.

Changes

  • Client settings UI for FlareSolverr enablement, URL, timeout, and connection check.
  • Server route /api/flaresolverr/verify using FlareSolverr sessions.list.
  • Tracker data fallback through FlareSolverr when Cloudflare challenge pages are detected.
  • New settings fields and migrations: flaresolverr_enabled, flaresolverr_url, flaresolverr_timeout_seconds.

Validation

  • bun run lint passed with existing warnings only.
  • bun run test passed.
  • bun run build passed.
  • Local dev migrations applied successfully.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request integrates FlareSolverr to bypass Cloudflare challenges when fetching tracker data, adding frontend settings, database schema updates, migrations, and backend adapter logic. Feedback on the changes highlights a critical runtime crash caused by using the non-existent z.url() method in Zod, an issue with URL resolution discarding subpaths due to leading slashes, and an opportunity to simplify a convoluted try-catch block in the tracker adapter's error handling.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

import { handleStandardValidation } from '@server/lib/validation';

const verifySchema = z.object({
flaresolverrUrl: z.url({ message: 'FlareSolverr URL is required' }).trim(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The z.url() method does not exist in standard Zod. Chaining .trim() on it will also fail. This will cause a runtime crash when the module is loaded. It should be corrected to use z.string().trim().url() instead.

Suggested change
flaresolverrUrl: z.url({ message: 'FlareSolverr URL is required' }).trim(),
flaresolverrUrl: z.string().trim().url({ message: 'FlareSolverr URL is required' }),

timeout: number;
cookies: string;
}): Promise<FlareSolverrSolution> {
const endpoint = new URL('/v1', normalizeServerUrl(params.serverUrl));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a leading slash in the input path ('/v1') with new URL() causes the resolution to be relative to the host root, discarding any subpath configured in the base URL (e.g., http://localhost:8191/proxy/ would resolve to http://localhost:8191/v1 instead of http://localhost:8191/proxy/v1). Removing the leading slash ('v1') ensures correct resolution when FlareSolverr is hosted behind a subpath proxy.

Suggested change
const endpoint = new URL('/v1', normalizeServerUrl(params.serverUrl));
const endpoint = new URL('v1', normalizeServerUrl(params.serverUrl));

serverUrl: string;
timeout: number;
}): Promise<void> {
const endpoint = new URL('/v1', normalizeServerUrl(params.serverUrl));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a leading slash in the input path ('/v1') with new URL() causes the resolution to be relative to the host root, discarding any subpath configured in the base URL. Removing the leading slash ('v1') ensures correct resolution when FlareSolverr is hosted behind a subpath proxy.

Suggested change
const endpoint = new URL('/v1', normalizeServerUrl(params.serverUrl));
const endpoint = new URL('v1', normalizeServerUrl(params.serverUrl));

Comment on lines +100 to +106
try {
assertNotCloudflareChallenge(root);
} catch (error) {
if (!(error instanceof CloudflareChallengeError)) {
throw error;
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This try-catch block is unnecessarily convoluted. It calls assertNotCloudflareChallenge which always throws an error, only to catch it and rethrow if it's not a CloudflareChallengeError. Since isCloudflareChallenge is already imported, you can simplify this to a direct check, which is much cleaner and easier to read.

    if (!isCloudflareChallenge(root)) {
      throw new Error('Server responded with 403');
    }

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e92861305d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

timeout: number;
cookies: string;
}): Promise<FlareSolverrSolution> {
const endpoint = new URL('/v1', normalizeServerUrl(params.serverUrl));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve FlareSolverr base paths when building endpoint

When a user configures FlareSolverr behind a reverse-proxy subpath such as http://host/flaresolverr, new URL('/v1', ...) discards the configured path and posts to http://host/v1 instead of http://host/flaresolverr/v1. In that deployment both the bypass request and connection test fail even though the configured service is reachable; build the API URL relative to the normalized base without a leading slash or otherwise preserve the pathname.

Useful? React with 👍 / 👎.

Repository owner deleted a comment from chatgpt-codex-connector Bot Jun 22, 2026
@defnone defnone merged commit 762a551 into main Jun 22, 2026
7 checks passed
@defnone defnone deleted the codex/flaresolverr-bypass branch June 22, 2026 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant