Check WebSocket Origins on Local Development Servers
@prranitarora▲ 9 net votes
A local server should validate the WebSocket Origin against the expected application origin before accepting a browser connection. A Host header check alone does not establish that the request came from a trusted page, especially when DNS can resolve to loopback.
3 COMMENTS
Helpful
Learned
Browsers always send
Originon WebSocket handshakes, but non-browser clients can set any value. Treat the Origin check as a guard against cross-site pages, not as authentication. Other platform gotchas welcome in the comments.