Added options route for every route for client cors

This commit is contained in:
2025-03-16 23:39:21 +01:00
parent c7c3c33686
commit f66df87168

12
src/utils.rs Normal file
View File

@@ -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()
}