I am building a REST API with actix-web. How do I configure CORS to accept requests from any origin?
Cors::new() // <- Construct CORS middleware builder
.allowed_origin("localhost:8081")
.allowed_methods(vec!["GET", "POST"])
.allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
.allowed_header(http::header::CONTENT_TYPE)
.max_age(3600)
The above code works from the web at localhost:8081
, but not from 0.0.0.0:8081
or 127.0.0.1:8081
. I tried "*"
to allow all, but it's not working. How do I allow all, or at least allow a specific origin and then pass multiple URLs?