Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions server/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ pub struct Cli {

/// Size for local cache
pub query_cache_size: u64,

/// CORS behaviour
pub cors: bool,
}

impl Cli {
Expand Down Expand Up @@ -130,6 +133,7 @@ impl Cli {
pub const DEFAULT_USERNAME: &'static str = "admin";
pub const DEFAULT_PASSWORD: &'static str = "admin";
pub const FLIGHT_PORT: &'static str = "flight-port";
pub const CORS: &'static str = "cors";

pub fn local_stream_data_path(&self, stream_name: &str) -> PathBuf {
self.local_staging_path.join(stream_name)
Expand Down Expand Up @@ -316,6 +320,16 @@ impl Cli {
.value_parser(value_parser!(u16))
.help("Port for Arrow Flight Querying Engine"),
)
.arg(
Arg::new(Self::CORS)
.long(Self::CORS)
.env("P_CORS")
.value_name("BOOL")
.required(false)
.default_value("true")
.value_parser(value_parser!(bool))
.help("Enable/Disable CORS, default disabled"),
)
.arg(
Arg::new(Self::LIVETAIL_CAPACITY)
.long(Self::LIVETAIL_CAPACITY)
Expand Down Expand Up @@ -451,6 +465,10 @@ impl FromArgMatches for Cli {
.get_one::<u16>(Self::FLIGHT_PORT)
.cloned()
.expect("default for flight port");
self.cors = m
.get_one::<bool>(Self::CORS)
.cloned()
.expect("default for CORS");
self.livetail_channel_capacity = m
.get_one::<usize>(Self::LIVETAIL_CAPACITY)
.cloned()
Expand Down
2 changes: 1 addition & 1 deletion server/src/handlers/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn metrics_path() -> String {
}

pub(crate) fn cross_origin_config() -> Cors {
if cfg!(feature = "debug") {
if !CONFIG.parseable.cors || cfg!(feature = "debug") {
Cors::permissive().block_on_origin_mismatch(false)
} else {
Cors::default().block_on_origin_mismatch(false)
Expand Down