fix: handle forwarded requests

proxied requests are now counted correctly
This commit is contained in:
2025-10-05 23:42:23 +02:00
parent 260039c307
commit 81fba8c4d0

View File

@@ -14,8 +14,8 @@ def api_greeting():
def api_global_catchall(received_request): def api_global_catchall(received_request):
ythdd_globals.apiRequests += 1 ythdd_globals.apiRequests += 1
if request.environ['REMOTE_ADDR'] != "127.0.0.1" or (ythdd_globals.isProxied and request.environ['X-Forwarded-For'] != "127.0.0.1"): if request.environ['REMOTE_ADDR'] != "127.0.0.1" or (ythdd_globals.isProxied and request.environ['HTTP_X_FORWARDED_FOR'] != "127.0.0.1"):
ythdd_globals.outsideApiHits += 1 ythdd_globals.outsideApiHits += 1
request_list = received_request.split('/') request_list = received_request.split('/')
api_version = request_list[0] api_version = request_list[0]