Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Cors
✓ use actix_cors::Cors;
Configures CORS middleware for an Actix Web server.
use actix_cors::Cors;
use actix_web::{web, App, HttpServer, HttpResponse};
async fn index() -> HttpResponse {
HttpResponse::Ok().body("Hello")
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
let cors = Cors::default()
.allowed_origin("https://example.com")
.allowed_methods(vec!["GET", "POST"]);
App::new()
.wrap(cors)
.route("/", web::get().to(index))
})
.bind("127.0.0.1:8080")?
.run()
.await
}
Audit
Dependencies
No dependency data recorded yet.