MCPcopy Create free account
hub / github.com/coder/mux / getFirstForwardedProtocol

Function getFirstForwardedProtocol

src/node/orpc/server.ts:249–258  ·  view source on GitHub ↗
(req: OriginValidationRequest)

Source from the content-addressed store, hash-verified

247}
248
249function getFirstForwardedProtocol(req: OriginValidationRequest): "http" | "https" | null {
250 const forwardedProtoHeader = getFirstHeaderValue(req, "x-forwarded-proto");
251 if (!forwardedProtoHeader) {
252 return null;
253 }
254
255 // Trust the client-facing hop. Additional values come from downstream/internal hops.
256 const firstHop = forwardedProtoHeader.split(",")[0] ?? "";
257 return normalizeProtocol(firstHop);
258}
259
260function getOriginProtocolOnExpectedHost(req: OriginValidationRequest): "http" | "https" | null {
261 const normalizedOrigin = normalizeOrigin(getFirstHeaderValue(req, "origin"));

Callers 1

getClientFacingProtocolFunction · 0.85

Calls 2

normalizeProtocolFunction · 0.85
getFirstHeaderValueFunction · 0.70

Tested by

no test coverage detected