Skip to content
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
14 changes: 9 additions & 5 deletions mono/src/server/https_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use axum::http::{self, Request, Uri};
use axum::response::Response;
use axum::routing::get;
use axum::Router;
use http::HeaderValue;
use lazy_static::lazy_static;
use regex::Regex;
use tower::ServiceBuilder;
Expand Down Expand Up @@ -100,7 +99,6 @@ pub async fn app(context: Context, host: String, port: u16) -> Router {
listen_addr: format!("http://{}:{}", host, port),
};

let cors_origin = HeaderValue::from_str(&config.oauth.clone().unwrap().ui_domain).expect("ui_domain in config not set");
// add RequestDecompressionLayer for handle gzip encode
// add TraceLayer for log record
// add CorsLayer to add cors header
Expand All @@ -114,9 +112,15 @@ pub async fn app(context: Context, host: String, port: u16) -> Router {
// Using Regular Expressions for Path Matching in Protocol
.route("/{*path}", get(get_method_router).post(post_method_router))
.layer(
ServiceBuilder::new().layer(CorsLayer::new().allow_origin(cors_origin).allow_headers(
vec![http::header::AUTHORIZATION, http::header::CONTENT_TYPE],
).allow_methods(Any)),
ServiceBuilder::new().layer(
CorsLayer::new()
.allow_origin(Any)
.allow_headers(vec![
http::header::AUTHORIZATION,
http::header::CONTENT_TYPE,
])
.allow_methods(Any),
),
)
.layer(TraceLayer::new_for_http())
.layer(RequestDecompressionLayer::new())
Expand Down
Loading