diegosouzapw/OmniRoute · error

FORBIDDEN_ORIGIN

FORBIDDEN_ORIGIN

Error message

Origin not allowed

What it means

WebSocket upgrade origin check: the browser-supplied Origin header failed isOriginAllowed, so the server rejects the drive-by cross-origin connection risk with a FORBIDDEN_ORIGIN frame and close code 4003. Non-browser clients without Origin are accepted only when bound to loopback.

Solutions

  1. Connect from the dashboard origin that is allowlisted
  2. Add the legitimate origin to the WS origin allowlist
  3. For CLI/MCP clients, connect via loopback so the Origin check is bypassed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/server/ws/liveServer.ts:517 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/484c7e26b2d2c9fc. Report an issue: GitHub.

Appendix: source

Thrown at src/server/ws/liveServer.ts:517

        ) {
          sendTo(ws, { type: "error", code: "RATE_LIMITED", message: "Too many early messages" });
          ws.close(4008, "Too many early messages");
          return;
        }
        pendingMessages.push(raw);
        return;
      }
      handleMessage(activeClientId, raw);
    });

    // Origin check — browsers always send Origin on the WS upgrade; reject
    // unknown origins to stop drive-by cross-origin WebSocket from a victim
    // page. Non-browser clients (CLI / MCP) omit Origin and are accepted
    // only when bound to loopback (see isOriginAllowed).
    const origin = request.headers["origin"];
    const originStr = Array.isArray(origin) ? origin[0] : origin;
    if (!isOriginAllowed(originStr)) {
      sendTo(ws, { type: "error", code: "FORBIDDEN_ORIGIN", message: "Origin not allowed" });
      ws.close(4003, "Forbidden origin");
      return;
    }

    // Enforce max clients
    if (clients.size >= MAX_CLIENTS) {
      sendTo(ws, { type: "error", code: "SERVER_FULL", message: "Max clients reached" });
      ws.close(1013, "Server full");
      return;
    }

    // Authorize
    const auth = await authorizeConnection(request);
    if (!auth.authorized) {
      sendTo(ws, { type: "error", code: "UNAUTHORIZED", message: auth.error || "Unauthorized" });
      ws.close(4001, "Unauthorized");
      return;
    }

View on GitHub (pinned to a179ffed5b)