use actix_web::{get,web,Result};
use actix_cors::Cors;
use actix_web::http::header;
#[get("/echo/{user_name}")]
async fn echo(path: web::Path<String>)-> Result<String>{
let user_name=path.into_inner();
return Ok(format!("Hello, {}",user_name));
}
#[actix_web::main]
async fn main() -> std::io::Result<()>{
use actix_web::{App,HttpServer};
HttpServer::new(|| {
let cors = Cors::default()
.allow_any_origin()
.allowed_methods(vec!["GET", "POST"])
.allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT])
.allowed_header(header::CONTENT_TYPE);
App::new()
.wrap(cors)
.service(echo)
})
.bind(("127.0.0.1", 8081))?
.run()
.await
}
以上方法,无法解决跨域问题
求佬帮助!!!