Skip to content

Commit

Permalink
cors for batch requests
Browse files Browse the repository at this point in the history
  • Loading branch information
sealsrock12 committed Feb 21, 2024
1 parent 8cd4067 commit 8f7d7ca
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 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 @@ -10,6 +10,7 @@ axum = "0.7.4"
chrono = "0.4.32"
clap = { version = "4.0", features = ["derive"] }
colored = "2.1.0"
http = "1.0.0"
levenshtein = "1.0.5"
log = "0.4.20"
nohash-hasher = "0.2.0"
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use serde::{Deserialize, Serialize};
use std::env;
use tower_http::cors::CorsLayer;
use usb::UsbCache;
use http::{Method,header};

/// Because the error that nom uses is rather lengthy and unintuitive, it's defined here
/// to simplify handling
Expand Down Expand Up @@ -221,7 +222,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.route("/api/usbs/", post(post_usbs_handler))
.route("/api/pcie/", get(get_pcie_handler))
.route("/api/pcie/", post(post_pcie_handler))
.layer(CorsLayer::new().allow_origin("*".parse::<HeaderValue>().unwrap()))
.layer(CorsLayer::new().allow_methods([Method::GET, Method::POST]).allow_headers([header::ACCEPT, header::CONTENT_TYPE]).allow_origin("*".parse::<HeaderValue>().unwrap()))
.with_state(AppState {
cpu_cache: CpuCache::new(),
usb_cache: UsbCache::new(),
Expand Down

0 comments on commit 8f7d7ca

Please sign in to comment.