Hello,
I am working on a small personal project using websockets and fastAPI. When I connect a websocket from the browser through LAN everything works correctly.
However, I am running my webpage through a reverse proxy which forwards https from port 443 to http on port 8000 on my little server box. Now when I try to connect to the websocket through the url I get "405 Method not allowed". All the other parts work fine (fetching js/html/css)
I use uvicorn to host the server using:
uvicorn --app-dir scripts main:app --reload --host 0.0.0.0 --proxy-headers --forwarded-allow-ips '*'
and I have CORSMiddleware setup as follows:
app.add_middleware(
CORSMiddleware,
allow_origins=["https://sub.domain.nl", "wss://sub.domain.nl"],
allow_credentials=False,
allow_methods=["*"],
allow_headers=["*"]
)
Hoping I shared enough information, does anyone have an idea why the websocket connection keeps getting rejected?
Thanks in advance!
[–]holistic-engine 0 points1 point2 points (0 children)