diff --git a/src/http/mod.rs b/src/http/mod.rs index 5e18cc7d1bf..d4705e45f80 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -1,3 +1,15 @@ +pub use cache::*; +pub use data_loader::*; +pub use data_loader_request::*; +use headers::HeaderValue; +pub use method::Method; +pub use request_context::RequestContext; +pub use request_handler::{handle_request, API_URL_PREFIX}; +pub use request_template::RequestTemplate; +pub use response::*; + +pub use crate::app_context::AppContext; + mod data_loader; mod cache; @@ -10,13 +22,5 @@ mod response; pub mod showcase; mod telemetry; -pub use cache::*; -pub use data_loader::*; -pub use data_loader_request::*; -pub use method::Method; -pub use request_context::RequestContext; -pub use request_handler::{handle_request, API_URL_PREFIX}; -pub use request_template::RequestTemplate; -pub use response::*; - -pub use crate::app_context::AppContext; +pub static TAILCALL_HTTPS_ORIGIN: HeaderValue = HeaderValue::from_static("https://tailcall.run"); +pub static TAILCALL_HTTP_ORIGIN: HeaderValue = HeaderValue::from_static("http://tailcall.run"); diff --git a/src/http/request_handler.rs b/src/http/request_handler.rs index 8b56fb8770f..c7a0e1a7190 100644 --- a/src/http/request_handler.rs +++ b/src/http/request_handler.rs @@ -16,7 +16,7 @@ use tracing_opentelemetry::OpenTelemetrySpanExt; use super::request_context::RequestContext; use super::telemetry::{get_response_status_code, RequestCounter}; -use super::{showcase, telemetry, AppContext}; +use super::{showcase, telemetry, AppContext, TAILCALL_HTTPS_ORIGIN, TAILCALL_HTTP_ORIGIN}; use crate::async_graphql_hyper::{GraphQLRequestLike, GraphQLResponse}; use crate::blueprint::telemetry::TelemetryExporter; use crate::config::{PrometheusExporter, PrometheusFormat}; @@ -326,7 +326,7 @@ pub async fn handle_request( let response = if app_ctx.blueprint.server.cors.is_some() { handle_request_with_cors::(req, app_ctx, &mut req_counter).await } else if let Some(origin) = req.headers().get(&header::ORIGIN) { - if origin == HeaderValue::from_static("https://tailcall.run") { + if origin == TAILCALL_HTTPS_ORIGIN || origin == TAILCALL_HTTP_ORIGIN { handle_origin_tailcall::(req, app_ctx, &mut req_counter).await } else { handle_request_inner::(req, app_ctx, &mut req_counter).await