Skip to content

Cannot connect to a WebSocket from another host #630

@gmile

Description

@gmile

After CSWSH fix in v1.28.2 (CVE-2026-22689), it seems like it's longer possible to connect to WS from another origin. My use-case for using the WS is to connect & watch the emails arriving to "inbox" during e2e tests. I have.

Tests need to listen for incoming emails via WebSocket (wss://email-service:8025/api/events) while the browser context is on https://web-service. After upgrading to v1.28.2+, all WebSocket connections fail with:

websocket: request origin not allowed by Upgrader.CheckOrigin

I found the --api-cors flag, but it seems it does not affect the WebSocket upgrade origin validation.

If this is a reasonable request then, perhaps, this could be solved by introducing another configuration flag, e.g. --ws-allowed-origins that accepts a comma-separated list of allowed origins for WebSocket connections:

To use like this, for example:

mailpit --ws-allowed-origins "https://web-service,https://localhost:3000"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions