fix: specify allowed headers on http responses (#2184)

This commit is contained in:
Gavin McDermott
2019-01-03 01:52:00 -08:00
committed by hashmap
parent c45486f2b9
commit 3092221997
+3 -1
View File
@@ -645,7 +645,7 @@ fn create_error_response(e: Error) -> Response<Body> {
Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.header("access-control-allow-origin", "*")
.header("access-control-allow-headers", "Content-Type")
.header("access-control-allow-headers", "Content-Type, Authorization")
.body(format!("{}", e).into())
.unwrap()
}
@@ -654,6 +654,7 @@ fn create_ok_response(json: &str) -> Response<Body> {
Response::builder()
.status(StatusCode::OK)
.header("access-control-allow-origin", "*")
.header("access-control-allow-headers", "Content-Type, Authorization")
.body(json.to_string().into())
.unwrap()
}
@@ -662,6 +663,7 @@ fn response<T: Into<Body>>(status: StatusCode, text: T) -> Response<Body> {
Response::builder()
.status(status)
.header("access-control-allow-origin", "*")
.header("access-control-allow-headers", "Content-Type, Authorization")
.body(text.into())
.unwrap()
}