1
0
Fork 1
Spiegel von https://github.com/dani-garcia/vaultwarden.git synchronisiert 2024-11-22 05:10:29 +01:00

Merge pull request #631 from vverst/cors-put

Use Access-Control-Allow-Method
Dieser Commit ist enthalten in:
Daniel García 2019-09-23 20:03:51 +02:00 committet von GitHub
Commit 8367d1d715
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -47,7 +47,7 @@ impl CORS {
impl Fairing for CORS { impl Fairing for CORS {
fn info(&self) -> Info { fn info(&self) -> Info {
Info { Info {
name: "Add CORS headers to requests", name: "CORS",
kind: Kind::Response kind: Kind::Response
} }
} }
@ -60,12 +60,12 @@ impl Fairing for CORS {
let req_allow_headers = CORS::get_header(&req_headers, "Access-Control-Request-Headers"); let req_allow_headers = CORS::get_header(&req_headers, "Access-Control-Request-Headers");
let req_allow_methods =CORS::get_header(&req_headers,"Access-Control-Request-Methods"); let req_allow_method = CORS::get_header(&req_headers,"Access-Control-Request-Method");
if request.method() == Method::Options || response.content_type() == Some(ContentType::JSON) { if request.method() == Method::Options || response.content_type() == Some(ContentType::JSON) {
// Requests with credentials need explicit values since they do not allow wildcards. // Requests with credentials need explicit values since they do not allow wildcards.
response.set_header(Header::new("Access-Control-Allow-Origin", req_allow_origin)); response.set_header(Header::new("Access-Control-Allow-Origin", req_allow_origin));
response.set_header(Header::new("Access-Control-Allow-Methods", req_allow_methods)); response.set_header(Header::new("Access-Control-Allow-Methods", req_allow_method));
response.set_header(Header::new("Access-Control-Allow-Headers", req_allow_headers)); response.set_header(Header::new("Access-Control-Allow-Headers", req_allow_headers));
response.set_header(Header::new("Access-Control-Allow-Credentials", "true")); response.set_header(Header::new("Access-Control-Allow-Credentials", "true"));
} }