Skip to content

Commit 120df62

Browse files
committed
Add headers to WebSocket connection
1 parent 5e49e3b commit 120df62

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

docs/api/client/servers.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,11 @@ const response = await axios.get(\`https://your-panel.com/api/client/servers/\${
680680
const { token, socket } = response.data.data;
681681

682682
// Connect to WebSocket
683-
const ws = new WebSocket(socket);
683+
const ws = new WebSocket(socket, {
684+
headers: {
685+
'Origin': 'https://your-panel.com'
686+
}
687+
});
684688

685689
ws.on('open', () => {
686690
// Authenticate
@@ -747,7 +751,11 @@ ws.run_forever()`
747751
Use the returned token and socket URL to establish a WebSocket connection:
748752

749753
```javascript
750-
const socket = new WebSocket('wss://node.example.com:8080/api/servers/d3aac109-e5e0-4331-b03e-3454f7e136dc/ws');
754+
const socket = new WebSocket('wss://node.example.com:8080/api/servers/d3aac109-e5e0-4331-b03e-3454f7e136dc/ws', {
755+
headers: {
756+
'Origin': 'https://your-panel.com'
757+
}
758+
});
751759

752760
socket.addEventListener('open', function (event) {
753761
// Authenticate with the WebSocket

0 commit comments

Comments
 (0)