fix: don't resuse invalidated cf_clearance cookie on CloudFlareInterceptor (#1916)

* fix: let FlareSolverr handle it's own `cf_clearance` cookie

also dedups cookies

* linting

* suggested changes

* my bad

* add to changelog
This commit is contained in:
David Brochero
2026-05-10 20:01:51 -03:00
committed by GitHub
parent edf376e3dd
commit 3064f51d25
2 changed files with 8 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- . - .
### Fixed ### Fixed
- (CloudFlareInterceptor) Don't send the `cf_clearance` cookie back to Flaresolverr
- (WebUI) Handle serving non-default webui with "bundled" - (WebUI) Handle serving non-default webui with "bundled"
- (WebUI) Wait until WebUI is ready to open in browser - (WebUI) Wait until WebUI is ready to open in browser

View File

@@ -103,7 +103,7 @@ class CloudflareInterceptor(
companion object { companion object {
private val ERROR_CODES = listOf(403, 503) private val ERROR_CODES = listOf(403, 503)
private val SERVER_CHECK = arrayOf("cloudflare-nginx", "cloudflare") private val SERVER_CHECK = arrayOf("cloudflare-nginx", "cloudflare")
private val COOKIE_NAMES = listOf("cf_clearance") val COOKIE_NAMES = listOf("cf_clearance")
private val CHROME_IMAGE_TEMPLATE_REGEX = Regex("""<title>(.*?) \(\d+×\d+\)</title>""") private val CHROME_IMAGE_TEMPLATE_REGEX = Regex("""<title>(.*?) \(\d+×\d+\)</title>""")
} }
} }
@@ -205,9 +205,12 @@ object CFClearance {
session = serverConfig.flareSolverrSessionName.value, session = serverConfig.flareSolverrSessionName.value,
sessionTtlMinutes = serverConfig.flareSolverrSessionTtl.value, sessionTtlMinutes = serverConfig.flareSolverrSessionTtl.value,
cookies = cookies =
network.cookieStore.get(originalRequest.url).map { network.cookieStore
FlareSolverCookie(it.name, it.value) .get(originalRequest.url)
}, .filter { it.name !in CloudflareInterceptor.COOKIE_NAMES }
.map { cookie ->
FlareSolverCookie(cookie.name, cookie.value)
},
returnOnlyCookies = onlyCookies, returnOnlyCookies = onlyCookies,
maxTimeout = timeout.inWholeMilliseconds.toInt(), maxTimeout = timeout.inWholeMilliseconds.toInt(),
postData = postData =