Replies: 1 comment 6 replies
-
I'm experiencing a similar issue. When I copy Cloudflare advanced protection cookies from my browser and plug them into a curl request, the request succeeds. When I use those same credentials with reqwest, I get a 403. For example, suppose that headers: {
"user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0",
"accept": "*/*"
"cookie": "__cf_bm=x; cookies=yes; cf_clearance=y",
} and sending the request returns 403 forbidden. When I then plug those into curl like so: curl $URL \
-H "accept: */*" \
-H "user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0" \
-H "cookie: __cf_bm=x; cookies=yes; cf_clearance=y" I get a 200 success. |
Beta Was this translation helpful? Give feedback.
-
A request made with reqwest to
https://www.crunchyroll.com/manifest.json
is blocked by Cloudflare's protection/challenge. However, a request to the same URL with the same headers usingcurl
works.This is a minimal reproducible example for this issue:
The client is configured with some additional headers, but removing them does not fix the issue. This example has been tested with these dependencies:
Note that the exact versions do not seem to matter, as this issue also happens in my actual project with older dependencies (and reqwest 0.11.23).
This code should download the URL and print it. When tested, it downloads an HTML page which seems to be Cloudflare's challenge, instead of the actual JSON manifest.
However, when I try to download the URL with the same headers using curl from the command line, it works:
I tested both ways multiple times (from the same computer), and the results were always the same. This issue also happens to some users of my project (filips123/PWAsForFirefox#482). It also seems to be specific to Crunchyroll, as it works fine with other Cloudflare-hosted websites.
Does reqwest send some different hidden headers than curl that make Cloudflare block the request? Or does it maybe do some advanced detection that can differentiate between curl and reqwest? So, is it possible to somehow configure reqwest client so it is not detected and blocked by Cloudflare?
Beta Was this translation helpful? Give feedback.
All reactions