Skip to content

Commit b248125

Browse files
committed
perf: Remove CORS middleware settings
1 parent 49a42a7 commit b248125

3 files changed

Lines changed: 0 additions & 26 deletions

File tree

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,3 @@ regex = "1.12"
4343
rusqlite = { version = "0.39", features = ["bundled"] }
4444
dirs = "6.0.0"
4545
base64 = "0.22.1"
46-
actix-cors = "0.7.1"

src/lib.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![allow(rustdoc::bare_urls)]
22
#![doc = include_str!("../README.md")]
33

4-
use actix_cors::Cors;
54
use actix_web::http::header;
65
use actix_web::{web, App, HttpServer};
76
use std::sync::Arc;
@@ -81,20 +80,7 @@ pub async fn start() -> std::io::Result<()> {
8180
);
8281

8382
HttpServer::new(move || {
84-
let mut cors = Cors::default()
85-
.allowed_methods(vec!["GET", "POST", "PUT", "DELETE"])
86-
.allowed_headers(vec![
87-
header::CONTENT_TYPE,
88-
header::AUTHORIZATION,
89-
header::HeaderName::from_static("apikey"),
90-
])
91-
.max_age(3600);
92-
for origin in &config.allowed_origins {
93-
cors = cors.allowed_origin(origin.as_str());
94-
}
95-
9683
App::new()
97-
.wrap(cors)
9884
.app_data(web::Data::new(state.clone()))
9985
.app_data(web::Data::new(pending.clone()))
10086
.app_data(web::Data::new(config.clone()))

src/settings.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ pub struct Config {
5353
pub port: u16,
5454
pub username: String,
5555
pub password: String,
56-
pub allowed_origins: Vec<String>,
5756

5857
pub apikey: String,
5958
pub workers: usize,
@@ -106,15 +105,6 @@ impl Config {
106105
.unwrap();
107106
let username = squire::get_env_var("username", None);
108107
let password = squire::get_env_var("password", None);
109-
let default_allowed = format!(
110-
"http://{host}:{port},http://0.0.0.0:{port},http://localhost:{port}",
111-
host = host,
112-
port = port
113-
);
114-
let allowed_origins = squire::get_env_var("allowed_origins", Some(&default_allowed))
115-
.split(',')
116-
.map(String::from)
117-
.collect();
118108

119109
let apikey = squire::get_env_var("apikey", None);
120110
if apikey.is_empty() {
@@ -203,7 +193,6 @@ impl Config {
203193
port,
204194
username,
205195
password,
206-
allowed_origins,
207196
apikey,
208197
workers,
209198
qbit_url,

0 commit comments

Comments
 (0)