Closed MartinSchmidt123 closed 8 months ago
I tried to get ALLOWED_IPS to work and found that the test
remote_addr in settings.ALLOWED_IPS
in https://github.com/mongkok/fastapi-debug-toolbar/blob/main/debug_toolbar/middleware.py#L25 always returns False because remote_addr is of type str and ALLOWED_IPS is a list of type IPv4Address.
False
remote_addr
str
ALLOWED_IPS
IPv4Address
Printing the variables in question returns for
print(f"{remote_addr} in {settings.ALLOWED_IPS}: {remote_addr in settings.ALLOWED_IPS}") print(f"{type(remote_addr)} {type(settings.ALLOWED_IPS[0])}")
the results
127.0.0.1 in [IPv4Address('127.0.0.1'), IPv4Address('1.2.3.4')]: False <class 'str'> <class 'ipaddress.IPv4Address'>
Thanks for the details @MartinSchmidt123 , please check the new release, ALLOWED_IPS settings was removed in favor of ALLOWED_HOSTS: Sequence[str] | None.
ALLOWED_HOSTS: Sequence[str] | None
I tried to get ALLOWED_IPS to work and found that the test
in https://github.com/mongkok/fastapi-debug-toolbar/blob/main/debug_toolbar/middleware.py#L25 always returns
False
becauseremote_addr
is of typestr
andALLOWED_IPS
is a list of typeIPv4Address
.Printing the variables in question returns for
the results