Open
Description
Most Actix-using services provide some user configuration via .yaml
files or CLI parameters. CORS is a common feature that would require to be configurable by the end user. Yet, the current CORS crate API is somewhat complex when it comes to translating end-user provided configuration into API calls.
I think it will be of great help for developers to suggest some ways of specifying CORS values via configuration and translating them to API calls. Note that this is different than the dynamic configuration via allowed_origin_fn
or similar.
Configuration Examples
Origins
cors-origins: *
cors-origins: example.com
cors-origins: [ example.com, example.org ]
let origins: String = config.cors_origins;
// FIXME: this won't work because it has to handle "*" differently?
Cors::default().allowed_origin(origins);
Methods
cors-methods: *
cors-methods: GET
cors-methods: [ GET, POST ]
// TODO: Rust example
Headers
cors-headers: *
cors-headers: AUTHORIZATION
cors-headers: [ AUTHORIZATION, ACCEPT ]
// TODO: Rust example