File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,4 +43,3 @@ regex = "1.12"
4343rusqlite = { version = " 0.39" , features = [" bundled" ] }
4444dirs = " 6.0.0"
4545base64 = " 0.22.1"
46- actix-cors = " 0.7.1"
Original file line number Diff line number Diff line change 11#![ allow( rustdoc:: bare_urls) ]
22#![ doc = include_str ! ( "../README.md" ) ]
33
4- use actix_cors:: Cors ;
54use actix_web:: http:: header;
65use actix_web:: { web, App , HttpServer } ;
76use 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 ( ) ) )
Original file line number Diff line number Diff 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,
You can’t perform that action at this time.
0 commit comments