Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cli arg disable cors torii proxy server #1904

Merged
merged 6 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion bin/torii/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ struct Args {
/// Chunk size of the events page when indexing using events
#[arg(long, default_value = "1000")]
events_chunk_size: u64,

/// Should cors be disabled
#[arg(long)]
no_cors: bool,
Larkooo marked this conversation as resolved.
Show resolved Hide resolved
}

#[tokio::main]
Expand Down Expand Up @@ -205,7 +209,8 @@ async fn main() -> anyhow::Result<()> {
)
.expect("Failed to start libp2p relay server");

let proxy_server = Arc::new(Proxy::new(args.addr, args.allowed_origins, Some(grpc_addr), None));
let proxy_server =
Arc::new(Proxy::new(args.addr, args.allowed_origins, Some(grpc_addr), None, args.no_cors));

let graphql_server = spawn_rebuilding_graphql_server(
shutdown_tx.clone(),
Expand Down
4 changes: 3 additions & 1 deletion crates/torii/server/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub struct Proxy {
allowed_origins: Vec<String>,
grpc_addr: Option<SocketAddr>,
graphql_addr: Arc<RwLock<Option<SocketAddr>>>,
no_cors: bool,
}

impl Proxy {
Expand All @@ -65,8 +66,9 @@ impl Proxy {
allowed_origins: Vec<String>,
grpc_addr: Option<SocketAddr>,
graphql_addr: Option<SocketAddr>,
no_cors: bool,
) -> Self {
Self { addr, allowed_origins, grpc_addr, graphql_addr: Arc::new(RwLock::new(graphql_addr)) }
Self { addr, allowed_origins, grpc_addr, graphql_addr: Arc::new(RwLock::new(graphql_addr)), no_cors }
}

pub async fn set_graphql_addr(&self, addr: SocketAddr) {
Expand Down
Loading