remove CORS support
This commit is contained in:
parent
e846e65cab
commit
927219667d
1 changed files with 1 additions and 22 deletions
23
src/main.rs
23
src/main.rs
|
@ -16,7 +16,6 @@ use std::error::Error;
|
||||||
|
|
||||||
use rocket::fs::FileServer;
|
use rocket::fs::FileServer;
|
||||||
use rocket::http::Method;
|
use rocket::http::Method;
|
||||||
use rocket_cors::{AllowedHeaders, AllowedOrigins, Cors};
|
|
||||||
|
|
||||||
use empty::*;
|
use empty::*;
|
||||||
use garbage::*;
|
use garbage::*;
|
||||||
|
@ -26,7 +25,6 @@ use get_ip::*;
|
||||||
async fn main() -> Result<(), Box<dyn Error>> {
|
async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
|
|
||||||
let cors = setup_cors().await?;
|
|
||||||
let routes = routes![get_ip::get_ip, get_backend_ip_php];
|
let routes = routes![get_ip::get_ip, get_backend_ip_php];
|
||||||
|
|
||||||
let garbage_routes = routes![
|
let garbage_routes = routes![
|
||||||
|
@ -47,7 +45,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
let routes = vec![routes, garbage_routes, empty_routes].concat();
|
let routes = vec![routes, garbage_routes, empty_routes].concat();
|
||||||
|
|
||||||
let mut rocketship = rocket::build().attach(cors).mount("/", routes);
|
let mut rocketship = rocket::build().mount("/", routes);
|
||||||
|
|
||||||
let asset_path = std::env::current_dir().unwrap().join("assets");
|
let asset_path = std::env::current_dir().unwrap().join("assets");
|
||||||
if asset_path.exists() {
|
if asset_path.exists() {
|
||||||
|
@ -60,22 +58,3 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn setup_cors() -> Result<Cors, Box<dyn Error>> {
|
|
||||||
let allowed_origins = AllowedOrigins::all();
|
|
||||||
let allowed_methods = vec![Method::Get, Method::Post]
|
|
||||||
.into_iter()
|
|
||||||
.map(From::from)
|
|
||||||
.collect();
|
|
||||||
let allowed_headers = AllowedHeaders::some(&["Content-Encoding", "Content-Type"]);
|
|
||||||
|
|
||||||
let cors = rocket_cors::CorsOptions {
|
|
||||||
allowed_origins,
|
|
||||||
allowed_methods,
|
|
||||||
allowed_headers,
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
.to_cors()?;
|
|
||||||
|
|
||||||
Ok(cors)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue