Skip to content

Commit

Permalink
fix: cors
Browse files Browse the repository at this point in the history
  • Loading branch information
zleyyij committed Jan 29, 2024
1 parent a295de9 commit 9005beb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod cpu;

use axum::extract::Query;
use axum::http::HeaderValue;
use axum::{extract::State, routing::get, Json, Router};
use chrono::Local;
use clap::Parser;
Expand Down Expand Up @@ -84,7 +85,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())
.layer(CorsLayer::new().allow_origin("*".parse::<HeaderValue>().unwrap()))
.with_state(AppState {
cpu_cache: CpuCache::new(),
});
Expand Down

0 comments on commit 9005beb

Please sign in to comment.