From 5ee893db33e32354594616b0e1d1dbd469f4fb53 Mon Sep 17 00:00:00 2001 From: TBC Dev Date: Tue, 14 Jul 2020 18:27:34 +0800 Subject: [PATCH] Add CORS Max-Age header --- rpc/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 3a3673b7b5d..f54b86f996c 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -162,6 +162,9 @@ pub use http_common::HttpMetaExtractor; use std::net::SocketAddr; +/// RPC HTTP Server header Access-Control-Max-Age +const CORS_MAX_AGE_SECONDS: u32 = 600; + /// RPC HTTP Server instance pub type HttpServer = http::Server; @@ -186,6 +189,7 @@ pub fn start_http( .keep_alive(keep_alive) .threads(threads) .cors(cors_domains) + .cors_max_age(CORS_MAX_AGE_SECONDS) .allowed_hosts(allowed_hosts) .health_api(("/api/health", "parity_nodeStatus")) .cors_allow_headers(AccessControlAllowHeaders::Any) @@ -217,6 +221,7 @@ pub fn start_http_with_middleware( .keep_alive(keep_alive) .threads(threads) .cors(cors_domains) + .cors_max_age(CORS_MAX_AGE_SECONDS) .allowed_hosts(allowed_hosts) .cors_allow_headers(AccessControlAllowHeaders::Any) .max_request_body_size(max_payload * 1024 * 1024)