Skip to content

Commit

Permalink
Merge pull request #45 from ivinjabraham/main
Browse files Browse the repository at this point in the history
add localhost to allowed origins
  • Loading branch information
hrideshmg authored Feb 4, 2025
2 parents 1e22635 + 3d3b983 commit 3b4e8f1
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] = [
"127.0.0.1".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 3b4e8f1

Please sign in to comment.