Skip to content

Commit

Permalink
fix: cors was incorrectly set
Browse files Browse the repository at this point in the history
  • Loading branch information
zleyyij committed Jan 29, 2024
1 parent 7a4770b commit a295de9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
25 changes: 24 additions & 1 deletion 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 @@ -16,3 +16,4 @@ nom = "7.1.3"
serde = { version = "1.0.195", features = ["derive"] }
serde_json = "1.0.111"
tokio = { version = "1.35.1", features = ["full"] }
tower-http = { version = "0.5.1", features = ["cors"] }
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use log::info;
use log::{Level, LevelFilter, Metadata, Record};
use serde::{Deserialize, Serialize};
use std::env;
use tower_http::cors::CorsLayer;
/// https://docs.rs/log/latest/log/#implementing-a-logger
struct SimpleLogger;

Expand Down Expand Up @@ -83,6 +84,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// create a new http router and register respective routes and handlers
let app = Router::new()
.route("/api/cpus/", get(get_cpu_handler))
.layer(CorsLayer::very_permissive())
.with_state(AppState {
cpu_cache: CpuCache::new(),
});
Expand Down

0 comments on commit a295de9

Please sign in to comment.