Express

CORS misconfiguration blocks Socket.io WebSocket connections

warning
securityUpdated Sep 21, 2025(via Exa)
Technologies:
How to detect:

Missing or improperly configured CORS headers prevent Socket.io connections when clients run on different domains or ports. 27-40% of socket-based apps experience connection failures due to CORS issues, resulting in blackholed or silently dropped connections.

Recommended action:

Configure explicit CORS origins in Socket.io server initialization. Set `credentials: true` when using authentication tokens or sessions. Avoid wildcard '*' origins with credentials. Ensure proxy servers preserve CORS headers. Verify OPTIONS preflight responses are handled correctly.