Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow all headers on cors #3653

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/router/src/cors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub fn cors(config: settings::CorsSettings) -> actix_cors::Cors {

let mut cors = actix_cors::Cors::default()
.allowed_methods(allowed_methods)
.allow_any_header()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I allow all the headers or just api-key, authorisation, content-type. Since that's what browser is asking for ref: access-control-request-headers: api-key,authorization,content-type. I guess this is common in most of the cases

cc: @jarnura @NishantJoshi00 @SanchithHegde

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on user's browser configuration, the headers that would be sent in the request would vary, and is not something we can predict. I think it's best to allow any request header.

.max_age(config.max_age);

if config.wildcard_origin {
Expand All @@ -15,6 +16,8 @@ pub fn cors(config: settings::CorsSettings) -> actix_cors::Cors {
for origin in &config.origins {
cors = cors.allowed_origin(origin);
}
// Only allow this in case if it's not wildcard origins. ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
cors = cors.supports_credentials();
}

cors
Expand Down
Loading