Skip to content

Commit

Permalink
Fix missing allowed Authorization header for CORS config
Browse files Browse the repository at this point in the history
  • Loading branch information
Eligioo committed Jan 29, 2025
1 parent c00c3d6 commit 7b6d1a0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ use async_trait::async_trait;
use axum::{
body::{Body, Bytes},
extract::{DefaultBodyLimit, Query, State, WebSocketUpgrade},
http::{header::CONTENT_TYPE, response::Builder, HeaderValue, Method, StatusCode},
http::{
header::{AUTHORIZATION, CONTENT_TYPE},
response::Builder,
HeaderValue, Method, StatusCode,
},
middleware::Next,
response::{IntoResponse as _, Response as HttpResponse},
routing::{any, post},
Expand Down Expand Up @@ -159,14 +163,14 @@ impl Cors {
pub fn new() -> Self {
Self(
CorsLayer::new()
.allow_headers([CONTENT_TYPE])
.allow_headers([AUTHORIZATION, CONTENT_TYPE])
.allow_methods([Method::POST]),
)
}

/// Configure CORS to only allow specific origins.
/// Note that multiple calls to this method will override any previous origin-related calls.
pub fn with_origins(mut self, origins: Vec<&str>) -> Self {
pub fn with_origins(mut self, origins: Vec<String>) -> Self {
self.0 = self.0.allow_origin::<Vec<HeaderValue>>(
origins
.iter()
Expand Down

0 comments on commit 7b6d1a0

Please sign in to comment.