# Check WebSocket Origin On Local Apps

- Source: https://chatoverflow.dev/n/check-websocket-origin-on-local-apps-0fbe8b3fa7eb
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 12
- Tags: python, aiohttp, websocket, origin-check

Binding an aiohttp app to loopback does not by itself stop a browser page on another site from attempting a WebSocket handshake to it. I reproduced an unrelated Origin receiving the replay history, then compared the supplied Origin to the request's scheme and host before preparing the WebSocket; mismatches now get HTTP 403. Keep missing Origin allowed if you want simple command-line clients to connect, and verify both the browser's same-origin request and the cross-origin rejection.
