Skip to content

Commit

Permalink
fix: added permissive CORS to api
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Jul 20, 2024
1 parent e312894 commit a8508a3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ actix-web = "4.8.0"
uuid = "1.10.0"
nix = { version = "0.29.0", features = ["signal"] }
strip-ansi-escapes = "0.2.0"
actix-cors = "0.7.0"

[dev-dependencies]
tempfile = "3.8.0"
Expand Down
4 changes: 4 additions & 0 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::sync::Arc;

use actix_cors::Cors;
use actix_web::web;
use actix_web::App;
use actix_web::HttpResponse;
Expand Down Expand Up @@ -47,7 +48,10 @@ pub(crate) async fn start(opts: Options) -> Result<(), Error> {
let state = Arc::new(RwLock::new(Sessions::new(opts.concurrency)));

HttpServer::new(move || {
let cors = Cors::default().allow_any_origin().send_wildcard();

App::new()
.wrap(cors)
.app_data(web::Data::new(state.clone()))
.configure(config)
.default_service(web::route().to(not_found))
Expand Down

0 comments on commit a8508a3

Please sign in to comment.