Skip to content

Commit

Permalink
Merge pull request #48 from amfoss/main
Browse files Browse the repository at this point in the history
backport fixes from main
  • Loading branch information
ivinjabraham authored Feb 6, 2025
2 parents eb676db + d00a7a1 commit a87748c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,15 @@ fn build_graphql_schema(

/// Abstraction over making the CORSLayer.
fn setup_cors() -> CorsLayer {
let origins: [HeaderValue; 2] = [
"http://127.0.0.1:3000".parse().unwrap(),
"https://home.amfoss.in".parse().unwrap(),
];

CorsLayer::new()
// Home should be the only website that accesses the API, bots and scripts do not trigger CORS AFAIK.
// This lets us restrict who has access to what in the API on the Home frontend.
.allow_origin(HeaderValue::from_static("https://home.amfoss.in"))
.allow_origin(origins)
.allow_methods([Method::GET, Method::POST, Method::OPTIONS])
.allow_headers(tower_http::cors::Any)
}

0 comments on commit a87748c

Please # to comment.