mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
expose traceresponse header in CORS (#644)
The [traceresponse](https://w3c.github.io/trace-context/#traceresponse-header) header needs to be exposed over CORS request's so that clients can retrieve for further processing. We emit this response header to represent tracecontext. ref [this](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers) for more info V3_GIT_ORIGIN_REV_ID: 7944c764343b201b37a635acfb927910202784ad
This commit is contained in:
parent
835668b03c
commit
f04bdc59d7
@ -1,3 +1,4 @@
|
||||
use axum::http::header::HeaderName;
|
||||
use reqwest::Method;
|
||||
use std::time::Duration;
|
||||
use tower_http::cors;
|
||||
@ -18,13 +19,15 @@ pub fn build_cors_layer(cors_allow_origin: &[String]) -> cors::CorsLayer {
|
||||
})
|
||||
})
|
||||
};
|
||||
|
||||
// Allow traceresponse to be retrievable on CORS
|
||||
let trace_response_header_name = HeaderName::from_static("traceresponse");
|
||||
cors::CorsLayer::new()
|
||||
.max_age(Duration::from_secs(24 * 60 * 60)) // 24 hours
|
||||
.allow_headers(cors::AllowHeaders::mirror_request())
|
||||
.allow_origin(cors_allow_origin)
|
||||
.allow_credentials(true)
|
||||
.allow_methods(vec![Method::GET, Method::POST, Method::OPTIONS])
|
||||
.expose_headers([trace_response_header_name])
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Loading…
Reference in New Issue
Block a user