π Trying to run this on a Wagtail project in Azure App Service (containerised), Iβm getting the following exception:
ValueError: '147.243.178.14:13250' does not appear to be an IPv4 or IPv6 address
[β¦]
File "/usr/local/lib/python3.8/site-packages/baipw/middleware.py", line 18, in __call__
response = self.process_request(request)
File "/usr/local/lib/python3.8/site-packages/baipw/middleware.py", line 35, in process_request
if self._is_ip_whitelisted(request):
File "/usr/local/lib/python3.8/site-packages/baipw/middleware.py", line 128, in _is_ip_whitelisted
ip_address = ipaddress.ip_address(self._get_client_ip(request))
File "/usr/local/lib/python3.8/ipaddress.py", line 53, in ip_address
raise ValueError('%r does not appear to be an IPv4 or IPv6 address' %
ValueError: '147.243.178.14:13250' does not appear to be an IPv4 or IPv6 address
This looks like it would be due to the port. Itβs not too clear to me which HTTP header might contain it though. Here is my hacky workaround to remove the port:
Edit: removed as my workaround was only working locally when manually setting a few specific headers.