Allowed hosts middleware — reject requests with unrecognized Host header.
Validates the Host header against a whitelist. Wildcard".example.com"
matches subdomains."*"allows all hosts (dev default).
middleware.allowed_hosts
| Name | Type | Default | Description |
|---|---|---|---|
type
|
|
— | |
qualified_name
|
|
— | |
element_type
|
|
— | |
description
|
|
— | |
source_file
|
|
— | |
line_number
|
|
— | |
is_autodoc
|
|
— | |
autodoc_element
|
|
— | |
_autodoc_template
|
|
— | |
_autodoc_url_path
|
|
— | |
_autodoc_page_type
|
|
— | |
title
|
|
— | |
doc_content_hash
|
|
— |
Symbols on this page
AllowedHostsMiddleware
class
Reject requests whose Host header does not match allowed_hosts.
Usage::
from chirp.middleware.allowed_hosts import AllowedHostsMiddleware
app.add_middleware(AllowedHostsMiddleware(("example.com", ".example.com")))
View source · /home/runner/work/chirp/chirp/site/../src/chirp/middleware/allowed_hosts.py:1