Replies: 5 comments 11 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.
-
|
I encountered a similar issue, but the error Cloudflare gave me was let res = match self
.client
.get("https://api.bgm.tv/v0/subjects/12")
.send()
.await
{
Ok(res) => res,
Err(e) => {
return Err(e.to_string());
}
};Even if I write it this way, the same error still occurs, but it works fine with curl. This is really strange. |
Beta Was this translation helpful? Give feedback.
-
|
I encountered this issue on a Cloudflare site too, including the part where other ways of sending the request like Postman or Curl worked fine. Enabling HTTP/2 and adding |
Beta Was this translation helpful? Give feedback.
-
|
Does it help if you use If you make a request from something that isn't Firefox while sending Requests from |
Beta Was this translation helpful? Give feedback.
-
|
I have got the same problem. I still got blocked by the website even with the #![allow(unused_imports)]
use reqwest::{self, tls};
use std::collections::HashMap;
use ureq;
static URL: &str = "https://yande.re/post.json";
// This will respond correctly
fn main() -> Result<(), ureq::Error> {
let res = ureq::get(URL).call()?.body_mut().read_to_string()?;
println!("{}", res);
Ok(())
}
// And this will always respond 404 Error
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let cli = reqwest::Client::new();
let res = cli.get(URL).send().await?;
dbg!(&res);
dbg!(&res.headers());
dbg!(res.text().await?);
Ok(())
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
A request made with reqwest to
https://www.crunchyroll.com/manifest.jsonis blocked by Cloudflare's protection/challenge. However, a request to the same URL with the same headers usingcurlworks.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:
{ "background_color": "#23252b", "display": "minimal-ui", "name": "Crunchyroll - Watch Popular Anime", "orientation": "any", "scope": "/", "short_name": "Crunchyroll", "start_url": "/?utm_medium=pwa_app_launch&utm_source=pwa", "theme_color": "#f47521", "description": "Stream the world’s largest anime library. Watch over 1,000 titles—from past seasons to new episodes fresh from Japan", "categories": ["entertainment", "video"], "icons": [ { "src": "https://crunchyroll.com/build/assets/img/pwa/512.png", "sizes": "512x512", "type": "image/png", "purpose": "any" }, { "src": "https://crunchyroll.com/build/assets/img/pwa/512-maskable.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" } ], "scope_extensions": [ { "origin": "www.crunchyroll.com" }, { "origin": "sso.crunchyroll.com" } ], "shortcuts": [ { "name": "View Watchlist", "short_name": "Watchlist", "url": "/watchlist?utm_medium=pwa_app_launch&utm_source=pwa_shortcut", "description": "Pick up where you left off with your favorite anime series and movies", "icons": [ { "src": "https://crunchyroll.com/build/assets/img/pwa/icons/watchlist-icon.png", "sizes": "96x96", "type": "image/png", "purpose": "any" } ] }, { "name": "Browse Anime", "short_name": "Browse", "url": "/videos/popular?utm_medium=pwa_app_launch&utm_source=pwa_shortcut", "description": "See all anime Crunchyroll has to offer by popularity, freshness, and genre", "icons": [ { "src": "https://crunchyroll.com/build/assets/img/pwa/icons/browse-icon.png", "sizes": "96x96", "type": "image/png", "purpose": "any" } ] }, { "name": "Search", "short_name": "Search", "url": "/search?utm_medium=pwa_app_launch&utm_source=pwa_shortcut", "description": "Search for anime on Crunchyroll", "icons": [ { "src": "https://crunchyroll.com/build/assets/img/pwa/icons/search-icon.png", "sizes": "96x96", "type": "image/png", "purpose": "any" } ] }, { "name": "View Crunchylists", "short_name": "Crunchylists", "url": "/crunchylists?utm_medium=pwa_app_launch&utm_source=pwa_shortcut", "description": "Create and manage your custom Crunchylists", "icons": [ { "src": "https://crunchyroll.com/build/assets/img/pwa/icons/crunchylists-icon.png", "sizes": "96x96", "type": "image/png", "purpose": "any" } ] }, { "name": "View History", "short_name": "History", "url": "/history?utm_medium=pwa_app_launch&utm_source=pwa_shortcut", "description": "See your most recently watched videos on Crunchyroll", "icons": [ { "src": "https://crunchyroll.com/build/assets/img/pwa/icons/history-icon.png", "sizes": "96x96", "type": "image/png", "purpose": "any" } ] } ], "id": "com.crunchyroll.pwa", "dir": "auto" }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