feat: set CORS headers on cfg debug only

This commit is contained in:
Sebastian Pravda 2022-11-29 09:30:00 +01:00
parent d72ef89abb
commit 859b8fbad8
No known key found for this signature in database
GPG key ID: F3BC84F08EFA3F57

View file

@ -31,12 +31,18 @@ impl Fairing for CORS {
}
}
#[cfg(debug_assertions)]
async fn on_response<'r>(&self, _request: &'r Request<'_>, response: &mut Response<'r>) {
response.set_header(Header::new("Access-Control-Allow-Origin", "http://localhost:5173"));
response.set_header(Header::new("Access-Control-Allow-Methods", "POST, GET, OPTIONS"));
response.set_header(Header::new("Access-Control-Allow-Headers", "content-type"));
response.set_header(Header::new("Access-Control-Allow-Credentials", "true"));
}
#[cfg(not(debug_assertions))]
async fn on_response<'r>(&self, _request: &'r Request<'_>, response: &mut Response<'r>) {
// TODO
}
}
#[options("/<_..>")]