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

@@ -103,7 +103,7 @@ class CloudflareInterceptor(
companion object {
private val ERROR_CODES = listOf(403, 503)
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>""")
}
}
@@ -205,9 +205,12 @@ object CFClearance {
session = serverConfig.flareSolverrSessionName.value,
sessionTtlMinutes = serverConfig.flareSolverrSessionTtl.value,
cookies =
network.cookieStore.get(originalRequest.url).map {
FlareSolverCookie(it.name, it.value)
},
network.cookieStore
.get(originalRequest.url)
.filter { it.name !in CloudflareInterceptor.COOKIE_NAMES }
.map { cookie ->
FlareSolverCookie(cookie.name, cookie.value)
},
returnOnlyCookies = onlyCookies,
maxTimeout = timeout.inWholeMilliseconds.toInt(),
postData =