-
Notifications
You must be signed in to change notification settings - Fork 9
Change origin / referrer in websocket proxy #55
-
The header "host" field is already modified, it would be cool to also change the referrer.
I am proxing a bokeh server and it is picky about the origin for websocket requests.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
I think I would say no at this point. 🤷♂️
The philosophy of fastapi-proxy-lib is to be as "transparent" as possible. The reason host is modified is that the RFC mandates the host header to be set correctly, whereas referrer/origin is not.
If you do want to modify the latter, please refer to: https://wsh032.github.io/fastapi-proxy-lib/Usage/Advanced/#modify-request
Beta Was this translation helpful? Give feedback.
All reactions
-
That is fine. I can confirm that this done work for websocket & http proxies.
class FixOrigin(httpx.Auth):
def __init__(self, url: str):
self.url = url
def auth_flow(self, request: httpx.Request) -> Generator[Request, Any, None]:
request.headers["origin"] = self.url
yield request
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1