Skip to content

Websockets broken for some clients in v2.2.0 #1711

@kingosticks

Description

@kingosticks

Clients that use websocket connections from local files, such as those use in Apache Cordova apps like Mopidy-Mobile, do not work in Mopidy v.2.2.0. Reported here.

This is because the Origin header for requests from local files may be set to something like 'file://' or 'null', depending on the browser. The current check_origin() implementation (silently) blocks these requests. To reproduce, create a file contain the following called blocked.html and open it in your web browser by navigating to it's file URI e.g. file:///home/fred/blocked.html.

<script src="http://localhost:6680/mopidy/mopidy.js"></script>
<script>
  var mopidy = new Mopidy({
    webSocketUrl: "ws://localhost:6680/mopidy/ws/"
  });
  mopidy.connect();
</script>
  • Chrome sends Origin: file://
  • Firefox sends Origin: null

This was introduced by #1668

Metadata

Metadata

Assignees

Labels

A-httpArea: HTTP frontend

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions