From 8fbf22a29b4cf6d31d5d7ac38ec5f66456f2bca3 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Tue, 24 Mar 2026 11:15:00 +0500 Subject: [PATCH] add proxy --- backend/proxy.py | 40 ++++++++++++++++++++++++++++++++++ backend/requirements-proxy.txt | 2 ++ 2 files changed, 42 insertions(+) create mode 100644 backend/proxy.py create mode 100644 backend/requirements-proxy.txt diff --git a/backend/proxy.py b/backend/proxy.py new file mode 100644 index 0000000..df17743 --- /dev/null +++ b/backend/proxy.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +from flask import Flask, request, Response +from curl_cffi import requests as curl_requests + +app = Flask(__name__) +BASE_URL = "https://app-production.dhiraagu.com.mv" + + +def proxy_request(target_url: str) -> Response: + headers = {"Host": "app-production.dhiraagu.com.mv"} + + for h in ["Authorization", "Content-Type", "Accept"]: + if h in request.headers: + headers[h] = request.headers[h] + + resp = curl_requests.request( + method=request.method, + url=target_url, + headers=headers, + data=request.get_data() or None, + impersonate="chrome", + timeout=30, + ) + + return Response(resp.content, resp.status_code, {"Content-Type": resp.headers.get("content-type", "application/json")}) + + +@app.route("/") +def subscriber_lookup(subscriber_id: int): + return proxy_request(f"{BASE_URL}/io/v1/info/subscribers/{subscriber_id}/dir") + + +@app.route("/", defaults={"path": ""}) +@app.route("/") +def catch_all(path: str): + return proxy_request(f"{BASE_URL}/{path}") + + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=8080) diff --git a/backend/requirements-proxy.txt b/backend/requirements-proxy.txt new file mode 100644 index 0000000..7958223 --- /dev/null +++ b/backend/requirements-proxy.txt @@ -0,0 +1,2 @@ +flask>=3.0.0 +curl_cffi>=0.6.0