mirror of
https://github.com/Xevion/dynamic-preauth.git
synced 2025-12-06 05:15:00 -06:00
Fix CORS options/ordering
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
use std::env;
|
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
|
use std::{env, vec};
|
||||||
|
|
||||||
use futures_util::{FutureExt, StreamExt};
|
use futures_util::{FutureExt, StreamExt};
|
||||||
use models::{IncomingMessage, OutgoingMessage};
|
use models::{IncomingMessage, OutgoingMessage};
|
||||||
@@ -356,7 +356,7 @@ async fn main() {
|
|||||||
|
|
||||||
let cors = Cors::new()
|
let cors = Cors::new()
|
||||||
.allow_origin(&origin)
|
.allow_origin(&origin)
|
||||||
.allow_methods(vec![Method::GET, Method::OPTIONS])
|
.allow_methods(vec![Method::GET])
|
||||||
.into_handler();
|
.into_handler();
|
||||||
tracing::debug!("CORS Allowed Origin: {}", &origin);
|
tracing::debug!("CORS Allowed Origin: {}", &origin);
|
||||||
|
|
||||||
@@ -369,7 +369,6 @@ async fn main() {
|
|||||||
|
|
||||||
let router = Router::new()
|
let router = Router::new()
|
||||||
.hoop(CatchPanic::new())
|
.hoop(CatchPanic::new())
|
||||||
.hoop(cors)
|
|
||||||
// /notify does not need a session, nor should it have one
|
// /notify does not need a session, nor should it have one
|
||||||
.push(Router::with_path("notify").post(notify))
|
.push(Router::with_path("notify").post(notify))
|
||||||
.push(
|
.push(
|
||||||
@@ -383,7 +382,7 @@ async fn main() {
|
|||||||
.push(Router::with_path("<**path>").get(static_dir)),
|
.push(Router::with_path("<**path>").get(static_dir)),
|
||||||
);
|
);
|
||||||
|
|
||||||
let service = Service::new(router).hoop(Logger::new());
|
let service = Service::new(router).hoop(cors).hoop(Logger::new());
|
||||||
|
|
||||||
let acceptor = TcpListener::new(addr).bind().await;
|
let acceptor = TcpListener::new(addr).bind().await;
|
||||||
Server::new(acceptor).serve(service).await;
|
Server::new(acceptor).serve(service).await;
|
||||||
|
|||||||
Reference in New Issue
Block a user