(req: OriginValidationRequest)
| 247 | } |
| 248 | |
| 249 | function 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 | |
| 260 | function getOriginProtocolOnExpectedHost(req: OriginValidationRequest): "http" | "https" | null { |
| 261 | const normalizedOrigin = normalizeOrigin(getFirstHeaderValue(req, "origin")); |
no test coverage detected