TrustedHostMiddleware class validates incoming HTTP Host headers against a list of allowed hosts. This helps prevent host header injection attacks and ensures requests are only processed for valid domains.
Parameters
List of allowed host values. Use
["*"] to allow all hosts (not recommended for production). Can include port numbers.Whether to redirect non-www hosts to their www equivalent when the www version is in the allowed hosts list.