Skip to content

Commit

Permalink
feat: Add optional CORS allow any option value in http server cli (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
kir-gadjello authored Jun 28, 2024
1 parent 0361479 commit 970922e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions router/src/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1534,11 +1534,15 @@ pub async fn run(
// map to go inside the option and then map to parse from String to HeaderValue
// Finally, convert to AllowOrigin
let allow_origin: Option<AllowOrigin> = cors_allow_origin.map(|cors_allow_origin| {
AllowOrigin::list(
cors_allow_origin
.into_iter()
.map(|origin| origin.parse::<HeaderValue>().unwrap()),
)
if cors_allow_origin.iter().any(|origin| origin == "*") {
AllowOrigin::any()
} else {
AllowOrigin::list(
cors_allow_origin
.into_iter()
.map(|origin| origin.parse::<HeaderValue>().unwrap()),
)
}
});

let prom_handle = prom_builder
Expand Down

0 comments on commit 970922e

Please sign in to comment.