See if RateLimit is cors issue (#303)

This commit is contained in:
Geometrically
2022-02-19 17:51:24 -07:00
committed by GitHub
parent 7c80b61666
commit c0c80c0fdf

View File

@@ -246,33 +246,33 @@ async fn main() -> std::io::Result<()> {
.max_age(3600) .max_age(3600)
.send_wildcard(), .send_wildcard(),
) )
.wrap( // .wrap(
RateLimiter::new(MemoryStoreActor::from(store.clone()).start()) // RateLimiter::new(MemoryStoreActor::from(store.clone()).start())
.with_identifier(|req| { // .with_identifier(|req| {
let connection_info = req.connection_info(); // let connection_info = req.connection_info();
let ip = // let ip =
String::from(if parse_var("CLOUDFLARE_INTEGRATION").unwrap_or(false) { // String::from(if parse_var("CLOUDFLARE_INTEGRATION").unwrap_or(false) {
if let Some(header) = req.headers().get("CF-Connecting-IP") { // if let Some(header) = req.headers().get("CF-Connecting-IP") {
header.to_str().map_err(|_| ARError::IdentificationError)? // header.to_str().map_err(|_| ARError::IdentificationError)?
} else { // } else {
connection_info // connection_info
.peer_addr() // .peer_addr()
.ok_or(ARError::IdentificationError)? // .ok_or(ARError::IdentificationError)?
} // }
} else { // } else {
connection_info // connection_info
.peer_addr() // .peer_addr()
.ok_or(ARError::IdentificationError)? // .ok_or(ARError::IdentificationError)?
}); // });
//
Ok(ip) // Ok(ip)
}) // })
.with_interval(std::time::Duration::from_secs(60)) // .with_interval(std::time::Duration::from_secs(60))
.with_max_requests(300) // .with_max_requests(300)
.with_ignore_ips( // .with_ignore_ips(
parse_strings_from_var("RATE_LIMIT_IGNORE_IPS").unwrap_or_default(), // parse_strings_from_var("RATE_LIMIT_IGNORE_IPS").unwrap_or_default(),
), // ),
) // )
.app_data(web::Data::new(pool.clone())) .app_data(web::Data::new(pool.clone()))
.app_data(web::Data::new(file_host.clone())) .app_data(web::Data::new(file_host.clone()))
.app_data(web::Data::new(indexing_queue.clone())) .app_data(web::Data::new(indexing_queue.clone()))