mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-18 05:51:17 +00:00
feat: set CORS headers on cfg debug only
This commit is contained in:
parent
d72ef89abb
commit
859b8fbad8
1 changed files with 6 additions and 0 deletions
|
|
@ -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("/<_..>")]
|
||||
|
|
|
|||
Loading…
Reference in a new issue