unhardcode websocket server location

This commit is contained in:
Jill 2021-10-20 16:25:00 +03:00
parent 87b3934356
commit be169d876e
2 changed files with 7 additions and 5 deletions

View File

@ -20,9 +20,7 @@ it's intended use is for small groups of people to self-host, and as such there'
3. `npm install`
4. replace all mentions of `deemix.oat.zone` in `public/index.html` with your own domain (and `wss://` with `ws://` if needed)
5. (optionally) put the service on pm2 like such: `pm2 start src/index.js --name deemix-web-frontend` (or just run it with `node src/index.js`)
4. (optionally) put the service on pm2 like such: `pm2 start src/index.js --name deemix-web-frontend` (or just run it with `node src/index.js`)
### nginx addenum

View File

@ -35,6 +35,10 @@ function setTheme(theme) {
});
}
function getWebsocketLocation() {
return window.window.location.replace('https://', 'wss://').replace('http://', 'ws://');
}
window.onload = () => {
// dirty theme hacks :tm:
@ -88,7 +92,7 @@ window.onload = () => {
let coverArt
document.getElementById('albums').innerHTML = '';
document.getElementById('progress-album').innerHTML = '<div class="lds-ring"><div></div><div></div><div></div><div></div></div>';
const ws = new WebSocket('wss://deemix.oat.zone/api/album?id=' + id);
const ws = new WebSocket(getWebsocketLocation() + 'api/album?id=' + id);
ws.onmessage = (m) => {
const d = JSON.parse(m.data);
@ -121,7 +125,7 @@ window.onload = () => {
let coverArt
document.getElementById('albums').innerHTML = '';
document.getElementById('progress-album').innerHTML = '<div class="lds-ring"><div></div><div></div><div></div><div></div></div>';
const ws = new WebSocket('wss://deemix.oat.zone/api/track?id=' + trackId);
const ws = new WebSocket(getWebsocketLocation() + 'api/track?id=' + trackId);
ws.onmessage = (m) => {
const d = JSON.parse(m.data);
console.log(d);