diff --git a/src/utils.rs b/src/utils.rs new file mode 100644 index 0000000..1c26a23 --- /dev/null +++ b/src/utils.rs @@ -0,0 +1,12 @@ +use actix_web::{options, HttpResponse, Responder}; + +// This is needed for the web client. +// This returns the same options for every path of the api +#[options("/{_:.*}")] +async fn options() -> impl Responder { + HttpResponse::Ok() + .append_header(("Access-Control-Allow-Origin", "*")) + .append_header(("Access-Control-Allow-Methods", "GET, OPTIONS")) + .append_header(("Access-Control-Allow-Headers", "Content-Type")) + .finish() +}