I am trying to proxy an external website (Flower monitoring URL running on different container) using python Fast API framework:
client = AsyncClient(base_url=f'http://containername:7800/monitor')
@app.get(“/monitor/{path:path}”)
async def tile_request(path: str):
req = client.build_request("GET", path)
r = await client.send(req, stream=True)
return StreamingResponse(
r.aiter_raw(),
background=BackgroundTask(r.aclose),
headers=r.headers
)
It is able to proxy the container URL for every path. For ex.
http://python_server:8001/monitor/dashboard --> http://containername:7800/monitor/dashboard
http://python_server:8001/monitor/tasks --> http://containername:7800/monitor/tasks
It works well. But it fails when the PATH has some query params in the URL.
For ex.
http://python_server:8001/monitor/dashboard?json=1&_=1641485992460 --> redirects to http://containername:7800/monitor/dashboard
(Please note that no query params are appended to the URL).
Can anyone please help with how we can proxy this external website's any path with any query param.