The retry logic in proxy_request is changed from a finite loop with max_retries to an infinite while loop that only retries on 5xx server errors or exceptions, removing the max_retries parameter and the fallback 503 error response.
Move the '..' detection to operate on the raw path string before normalization, ensuring path traversal attempts are caught even when normpath would collapse them. Also apply the same early check to api_parsed_url.path in proxy_request, preventing bypass via normalized path segments.