Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document recommended CORS config in a server environment #359

Open
nyurik opened this issue Oct 28, 2023 · 0 comments
Open

Document recommended CORS config in a server environment #359

nyurik opened this issue Oct 28, 2023 · 0 comments
Labels
A-cors Project: actix-cors C-documentation Improvements or additions to documentation

Comments

@nyurik
Copy link

nyurik commented Oct 28, 2023

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
@robjtede robjtede added C-documentation Improvements or additions to documentation A-cors Project: actix-cors labels Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cors Project: actix-cors C-documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants