Added options route for every route for client cors
This commit is contained in:
12
src/utils.rs
Normal file
12
src/utils.rs
Normal 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()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user