From 428fcf697a26f44ae27d00106c990a4ae0006a8a Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sat, 23 Jul 2022 13:49:26 +0100 Subject: [PATCH] Ensure CORS headers are set on failed HTTP responses Closes #6 --- src/net/key.rs | 3 +-- src/net/mod.rs | 2 ++ src/net/signin.rs | 3 +-- src/net/signup.rs | 3 +-- src/net/sql.rs | 3 +-- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/net/key.rs b/src/net/key.rs index 7f10a6dc..207ab5fe 100644 --- a/src/net/key.rs +++ b/src/net/key.rs @@ -1,6 +1,5 @@ use crate::dbs::DB; use crate::err::Error; -use crate::net::head; use crate::net::output; use crate::net::session; use bytes::Bytes; @@ -112,7 +111,7 @@ pub fn config() -> impl Filter Result<(), Error> { let net = net.with(head::version()); // Specify a generic server header let net = net.with(head::server()); + // Set cors headers on all requests + let net = net.with(head::cors()); // Log all requests to the console let net = net.with(log::write()); diff --git a/src/net/signin.rs b/src/net/signin.rs index 89731d81..625ea6f9 100644 --- a/src/net/signin.rs +++ b/src/net/signin.rs @@ -1,5 +1,4 @@ use crate::err::Error; -use crate::net::head; use bytes::Bytes; use std::str; use surrealdb::sql::Value; @@ -20,7 +19,7 @@ pub fn config() -> impl Filter Result { diff --git a/src/net/signup.rs b/src/net/signup.rs index b0498f00..8689c056 100644 --- a/src/net/signup.rs +++ b/src/net/signup.rs @@ -1,5 +1,4 @@ use crate::err::Error; -use crate::net::head; use bytes::Bytes; use std::str; use surrealdb::sql::Value; @@ -20,7 +19,7 @@ pub fn config() -> impl Filter Result { diff --git a/src/net/sql.rs b/src/net/sql.rs index 14d6269c..986f9999 100644 --- a/src/net/sql.rs +++ b/src/net/sql.rs @@ -1,6 +1,5 @@ use crate::dbs::DB; use crate::err::Error; -use crate::net::head; use crate::net::output; use crate::net::session; use bytes::Bytes; @@ -30,7 +29,7 @@ pub fn config() -> impl Filter