Fix CORS method not allowed
This commit is contained in:
@@ -9,7 +9,7 @@ use axum::{
|
||||
http::{HeaderValue, Method, StatusCode, Uri},
|
||||
};
|
||||
use tower::{ServiceBuilder, timeout::TimeoutLayer};
|
||||
use tower_http::cors::{AllowHeaders, AllowOrigin, CorsLayer};
|
||||
use tower_http::cors::{AllowHeaders, AllowMethods, AllowOrigin, CorsLayer};
|
||||
use tracing::warn;
|
||||
|
||||
use crate::{configs::server::CORSSettings, routes::AppState};
|
||||
@@ -34,6 +34,7 @@ pub fn apply_root_middleware(
|
||||
pub fn get_cors_layer(cors_settings: Arc<CORSSettings>) -> CorsLayer {
|
||||
let mut cors_layer = CorsLayer::new()
|
||||
.allow_credentials(true)
|
||||
.allow_methods(AllowMethods::mirror_request())
|
||||
.allow_headers(AllowHeaders::mirror_request());
|
||||
|
||||
let allowed_origins = &cors_settings.allowed_origins;
|
||||
|
||||
Reference in New Issue
Block a user