This FastAPI application serves as an HTTP proxy, forwarding client requests to an upstream API server and relaying the server's response back to the client. It supports arbitrary paths and HTTP methods, providing a versatile proxy solution for various API interactions.
- Python 3.6 or higher
- FastAPI
- Uvicorn
- HTTPX
- Clone the repository to your local machine.
- Navigate to the project directory.
- Create a virtual environment:
python3 -m venv venv
- Activate the virtual environment:
source venv/bin/activate
- Install the necessary packages:
pip install fastapi uvicorn httpx
To launch the proxy server, execute the following command within the project directory:
uvicorn proxy_app:app --reload
The server will be accessible at http://127.0.0.1:8000
. To route requests through the proxy, direct them to the proxy server, specifying the desired path and method. The proxy will then forward the request to the matching path on the upstream API server.
Should you encounter any problems, verify the following:
- The virtual environment is active.
- All required dependencies have been installed.
- The server is operational and reachable.
For more specific error information, consult the server logs for detailed stack traces and error messages.