-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06cc3c7
commit b2cf587
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use rocket::fairing::{Fairing, Info, Kind}; | ||
use rocket::http::Header; | ||
use rocket::{Request, Response}; | ||
|
||
pub struct CORS; | ||
|
||
#[rocket::async_trait] | ||
impl Fairing for CORS { | ||
fn info(&self) -> Info { | ||
Info { | ||
name: "Add CORS headers to responses", | ||
kind: Kind::Response, | ||
} | ||
} | ||
|
||
async fn on_response<'r>(&self, _req: &'r Request<'_>, res: &mut Response<'r>) { | ||
res.set_header(Header::new("Access-Control-Allow-Origin", "*")); | ||
res.set_header(Header::new( | ||
"Access-Control-Allow-Methods", | ||
"POST, GET, PATCH, OPTIONS", | ||
)); | ||
res.set_header(Header::new("Access-Control-Allow-Headers", "*")); | ||
res.set_header(Header::new("Access-Control-Allow-Credentials", "true")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod compress; | ||
pub mod core; | ||
pub mod cors; | ||
pub mod jwt; | ||
pub mod routes; | ||
pub mod system; | ||
|