Skip to main content

localhost_host_middleware

Function localhost_host_middleware 

Source
pub async fn localhost_host_middleware(
    req: Request<Body>,
    next: Next,
) -> impl IntoResponse
Expand description

Axum middleware that rejects requests with non-localhost Host headers.

Prevents DNS rebinding attacks against the dev API (spec section 18.10.1). Returns HTTP 403 if the Host header is missing or does not match a localhost address.