I want to use the crate rocket_cors
for Rocket v0.5.0-rc.2 but it does not compile because "the trait bound 'Cors: Fairing' is not satisfied".
Here is my Cargo.toml:
# --snip--
[dependencies]
rocket = { version = "0.5.0-rc.2", features = [ "json" ] }
rocket_cors = { version = "0.5.2", default-features = false }
# --snip--
And here is my rocket()
function:
fn rocket() -> _ {
let cors = rocket_cors::CorsOptions {
allowed_origins: AllowedOrigins::all(),
allowed_headers: AllowedHeaders::some(&["Authorization", "Accept"]),
allow_credentials: true,
..Default::default()
}
.to_cors()
.unwrap();
rocket::build()
.attach(DbConnection::fairing())
.attach(cors) // <- Here's the error: "the trait `Fairing` is not implemented for `Cors`"
.mount("/", routes![get_tasks])
}
I won't have a problem if the solution is using another CORS crate either.