Guide: streamlit FastAPI websocket proxy / API-Gateway

I was having too much trouble trying to make FastAPI and Streamlit work together for my API-Gateway recently. The primary problem was configuring websocket connection between FastAPI, Streamlit and browser. However, after a few days of trials and errors I’ve come up with a fairly simple solution, hope somebody will find it useful:

PS: It’s also very important to not overload streamlit with too lengthy custom cookies