Skip to content

Commit 8cb5d95

Browse files
committed
chore: remove headers through guard
1 parent a7d0289 commit 8cb5d95

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

engine/packages/guard-core/src/proxy_service.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ use crate::{
3535
request_context::RequestContext,
3636
};
3737

38+
const X_RIVET_TARGET: HeaderName = HeaderName::from_static("x-rivet-target");
39+
const X_RIVET_ACTOR: HeaderName = HeaderName::from_static("x-rivet-actor");
40+
const X_RIVET_TOKEN: HeaderName = HeaderName::from_static("x-rivet-token");
3841
pub const X_FORWARDED_FOR: HeaderName = HeaderName::from_static("x-forwarded-for");
3942
pub const X_RIVET_ERROR: HeaderName = HeaderName::from_static("x-rivet-error");
43+
4044
const ROUTE_CACHE_TTL: Duration = Duration::from_secs(60 * 10); // 10 minutes
4145
const PROXY_STATE_CACHE_TTL: Duration = Duration::from_secs(60 * 60); // 1 hour
4246
const WEBSOCKET_CLOSE_LINGER: Duration = Duration::from_millis(100); // Keep TCP connection open briefly after WebSocket close
@@ -1060,6 +1064,7 @@ impl ProxyService {
10601064
}
10611065
}
10621066

1067+
/// Modifies the incoming request before it is proxied.
10631068
fn proxied_request_builder(
10641069
&self,
10651070
req_parts: &hyper::http::request::Parts,
@@ -1089,13 +1094,16 @@ impl ProxyService {
10891094
.method(req_parts.method.clone())
10901095
.uri(url.to_string());
10911096

1092-
// Add proxy headers
1093-
{
1094-
let headers = builder
1095-
.headers_mut()
1096-
.expect("request builder unexpectedly in error state");
1097-
add_proxy_headers_with_addr(headers, &req_parts.headers, self.remote_addr)?;
1098-
}
1097+
// Modify proxy headers
1098+
let headers = builder
1099+
.headers_mut()
1100+
.expect("request builder unexpectedly in error state");
1101+
1102+
headers.remove(X_RIVET_TARGET);
1103+
headers.remove(X_RIVET_ACTOR);
1104+
headers.remove(X_RIVET_TOKEN);
1105+
1106+
add_proxy_headers_with_addr(headers, &req_parts.headers, self.remote_addr)?;
10991107

11001108
Ok(builder)
11011109
}

engine/packages/guard/src/routing/pegboard_gateway.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::{errors, shared_state::SharedState};
1010

1111
const ACTOR_READY_TIMEOUT: Duration = Duration::from_secs(10);
1212
pub const X_RIVET_ACTOR: HeaderName = HeaderName::from_static("x-rivet-actor");
13-
pub const X_RIVET_AMESPACE: HeaderName = HeaderName::from_static("x-rivet-namespace");
1413
const WS_PROTOCOL_ACTOR: &str = "rivet_actor.";
1514

1615
/// Route requests to actor services using path-based routing

0 commit comments

Comments
 (0)