Skip to content

Commit

Permalink
[rpc] Add CORS headers on 404 response (tezedge#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiencs authored and tizoc committed Jun 13, 2021
1 parent 06ba2b6 commit b0fd1f7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rpc/src/lib.rs
Expand Up @@ -115,13 +115,20 @@ pub(crate) fn result_to_empty_json_response(
pub(crate) fn empty() -> ServiceResult {
Ok(Response::builder()
.status(StatusCode::from_u16(204)?)
.header(hyper::header::ACCESS_CONTROL_ALLOW_ORIGIN, "*")
.header(hyper::header::ACCESS_CONTROL_ALLOW_HEADERS, "Content-Type")
.header(hyper::header::ACCESS_CONTROL_ALLOW_HEADERS, "content-type")
.body(Body::empty())?)
}

/// Generate 404 response
pub(crate) fn not_found() -> ServiceResult {
Ok(Response::builder()
.status(StatusCode::from_u16(404)?)
.header(hyper::header::CONTENT_TYPE, "text/plain")
.header(hyper::header::ACCESS_CONTROL_ALLOW_ORIGIN, "*")
.header(hyper::header::ACCESS_CONTROL_ALLOW_HEADERS, "Content-Type")
.header(hyper::header::ACCESS_CONTROL_ALLOW_HEADERS, "content-type")
.body(Body::from("not found"))?)
}

Expand Down

0 comments on commit b0fd1f7

Please sign in to comment.