generated from ElnuDev/rust-project
Fix CORS policy
This commit is contained in:
parent
412ca4e538
commit
ba6f91f672
6 changed files with 31 additions and 5 deletions
|
@ -19,3 +19,4 @@ lazy_static = "1.4.0"
|
|||
rand = "0.8.5"
|
||||
serde_json = "1.0.104"
|
||||
clap = { version = "4.3.21", features = ["derive"] }
|
||||
actix-cors = "0.6.4"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use actix_cors::Cors;
|
||||
use utils::error::Result;
|
||||
|
||||
use actix_web::{get, http::header, web, App, HttpResponse, HttpServer, Responder};
|
||||
|
@ -72,13 +73,14 @@ async fn route_query_index(path: web::Path<(String, usize)>) -> Result<impl Resp
|
|||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| {
|
||||
HttpServer::new(||
|
||||
App::new()
|
||||
.service(route_query_list)
|
||||
.service(route_query)
|
||||
.service(route_query_random)
|
||||
.service(route_query_index)
|
||||
})
|
||||
.wrap(Cors::permissive())
|
||||
)
|
||||
.bind(("127.0.0.1", Args::parse().port))?
|
||||
.run()
|
||||
.await
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue