Add ability to configure CORS header (#1345)

## Issue Addressed

https://github.com/sigp/lighthouse/issues/1177

## Proposed Changes

Add a command line option (`--http-allow-origin`) and a config item for configuring the `Access-Control-Allow-Origin` response header.  This should unblock making XMLHttpRequests.
This commit is contained in:
Adam Szkoda
2020-07-16 07:23:14 +00:00
parent 4a01f44206
commit fc5e6cbbb0
9 changed files with 210 additions and 152 deletions

View File

@@ -38,6 +38,9 @@ pub struct Config {
pub listen_address: Ipv4Addr,
/// The port the REST API HTTP server will listen on.
pub port: u16,
/// If something else than "", a 'Access-Control-Allow-Origin' header will be present in
/// responses. Put *, to allow any origin.
pub allow_origin: String,
}
impl Default for Config {
@@ -46,6 +49,7 @@ impl Default for Config {
enabled: false,
listen_address: Ipv4Addr::new(127, 0, 0, 1),
port: 5052,
allow_origin: "".to_string(),
}
}
}