Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Change origin / referrer in websocket proxy #55

justinmann started this conversation in Ideas
Discussion options

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.

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

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

You must be logged in to vote
1 reply
Comment options

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
enhancement New feature or request
Converted from issue

This discussion was converted from issue #54 on March 10, 2025 22:04.

AltStyle によって変換されたページ (->オリジナル) /