discordjs / RPC

A simple RPC client for Discord
MIT License
459 stars 190 forks source link

connect via Browser? #135

Closed tiptronic closed 3 years ago

tiptronic commented 3 years ago

Did someone manage to connect to RPC from a browser (not Node)?

If I do:

new WebSocket(`ws://127.0.0.1:${port}/?v=1&client_id=${this.client.clientId}`);

the socket is closed immediately with an an error 'Invalid Origin' (4001).

CloseEvent {isTrusted: true, wasClean: true, code: 4001, reason: "Invalid Origin", type: "close",

My application is whitelisted in the RPC and the above code works fine from Node or Electron (where I can specify the 'origin' explicitely when connecting to the Websocket... but I couldn't figure out, how to connect from a browser window...

Any ideas?