feat: add cors rules to actix (#3646)

This commit is contained in:
Kartikeya Hegde
2024-02-14 10:26:44 +00:00
committed by GitHub
parent c5343dfcc2
commit e702341c64
10 changed files with 91 additions and 15 deletions

View File

@ -91,7 +91,7 @@ pub fn mk_app(
InitError = (),
>,
> {
let mut server_app = get_application_builder(request_body_limit);
let mut server_app = get_application_builder(request_body_limit, state.conf.cors.clone());
#[cfg(feature = "dummy_connector")]
{
@ -231,6 +231,7 @@ impl Stop for mpsc::Sender<()> {
pub fn get_application_builder(
request_body_limit: usize,
cors: settings::CorsSettings,
) -> actix_web::App<
impl ServiceFactory<
ServiceRequest,
@ -257,7 +258,7 @@ pub fn get_application_builder(
))
.wrap(middleware::default_response_headers())
.wrap(middleware::RequestId)
.wrap(cors::cors())
.wrap(cors::cors(cors))
// this middleware works only for Http1.1 requests
.wrap(middleware::Http400RequestDetailsLogger)
.wrap(middleware::LogSpanInitializer)