Skip to content

Commit

Permalink
Return CORS header for / in case of NotFound
Browse files Browse the repository at this point in the history
Return CORS header for / in case of NotFound, when there is an otherwise
valid server. nostrudel needs this to be able to add the media server in
the first place.
  • Loading branch information
laanwj authored and ibz committed Sep 2, 2024
1 parent f625392 commit a23f9fc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ async fn handle_index(request: Request<State>) -> tide::Result<Response> {
let resources = site.resources.read().unwrap();
match resources.get("/index") {
Some(..) => Ok(render_and_build_response(&site, "/index".to_owned())),
None => Ok(Response::new(StatusCode::NotFound)),
None => Ok(Response::builder(StatusCode::NotFound)
.header("Access-Control-Allow-Origin", "*")
.build())
}
} else {
return Ok(Response::new(StatusCode::NotFound));
Expand Down

0 comments on commit a23f9fc

Please sign in to comment.