Skip to content

Commit

Permalink
Allow more headers in CORS policies (#32637)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: a008a79455d0c85bc909892952ff0417c7527d09
  • Loading branch information
thomasballinger authored and Convex, Inc. committed Dec 28, 2024
1 parent bbbf5f1 commit 09693d8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
10 changes: 7 additions & 3 deletions crates/common/src/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use http::{
HeaderName,
HeaderValue,
ACCEPT,
ACCEPT_LANGUAGE,
AUTHORIZATION,
CONTENT_TYPE,
REFERER,
Expand Down Expand Up @@ -1139,12 +1140,15 @@ impl<T: fmt::Display> fmt::Display for LogOptFmt<T> {
pub fn cli_cors() -> CorsLayer {
CorsLayer::new()
.allow_headers(vec![
CONTENT_TYPE,
AUTHORIZATION,
"baggage".parse().unwrap(),
"sentry-trace".parse().unwrap(),
ACCEPT,
ACCEPT_LANGUAGE,
AUTHORIZATION,
CONTENT_TYPE,
CONVEX_CLIENT_HEADER,
REFERER,
USER_AGENT,
CONVEX_CLIENT_HEADER,
])
.allow_credentials(true)
.allow_methods(vec![
Expand Down
16 changes: 15 additions & 1 deletion crates/local_backend/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ use common::{
};
use http::{
header::{
ACCEPT,
ACCEPT_LANGUAGE,
AUTHORIZATION,
CONTENT_TYPE,
REFERER,
USER_AGENT,
},
request,
HeaderValue,
Expand Down Expand Up @@ -341,7 +345,17 @@ where

pub fn cors() -> CorsLayer {
CorsLayer::new()
.allow_headers(vec![CONTENT_TYPE, "sentry-trace".parse().unwrap(), "baggage".parse().unwrap(), CONVEX_CLIENT_HEADER, AUTHORIZATION])
.allow_headers(vec![
"baggage".parse().unwrap(),
"sentry-trace".parse().unwrap(),
ACCEPT,
ACCEPT_LANGUAGE,
AUTHORIZATION,
CONTENT_TYPE,
CONVEX_CLIENT_HEADER,
REFERER,
USER_AGENT,
])
.allow_credentials(true)
.allow_methods(vec![
Method::GET,
Expand Down

0 comments on commit 09693d8

Please sign in to comment.