use correct scheme in prod mode
This commit is contained in:
parent
90dff5ed7b
commit
913b0df0b0
@ -1,3 +1,4 @@
|
||||
import { dev } from '$app/environment';
|
||||
import type { TrackWithId } from "./types";
|
||||
|
||||
const API_VERSION: number = 20;
|
||||
@ -16,8 +17,6 @@ interface Message {
|
||||
type MessageType = 'request' | 'response' | 'broadcast';
|
||||
type RequestCallback = (arg0: Message | null) => void;
|
||||
|
||||
type Category = 'album' | 'artist' | 'album_artist' | 'genre' | 'playlist';
|
||||
|
||||
interface Callbacks {
|
||||
onDisconnect: (authenticated: boolean, reason: string) => void;
|
||||
onConnect: (initial: Message) => void;
|
||||
@ -52,7 +51,8 @@ export class MetadataCommunicator {
|
||||
connect(address: string, password: string) {
|
||||
this.close();
|
||||
|
||||
this.ws = new WebSocket(`ws://${address}`);
|
||||
const scheme = dev ? "ws" : "wss";
|
||||
this.ws = new WebSocket(`${scheme}://${address}`);
|
||||
|
||||
this.ws.addEventListener('open', (event) => {
|
||||
this.makeRequest("authenticate", 'request', { password }, (msg) => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { get, writable } from 'svelte/store';
|
||||
import { type ResourceId, type Track, type TrackId, type TrackWithId, LoopKind } from './types';
|
||||
import { dev } from '$app/environment';
|
||||
|
||||
function writableStorage(key: string, defaultValue: string) {
|
||||
const store = writable(localStorage.getItem(key) ?? defaultValue);
|
||||
@ -11,11 +12,13 @@ export const address = writableStorage("address", "127.0.0.1:5505");
|
||||
export const token = writableStorage("token", "");
|
||||
|
||||
export function makeThumbnailUrl(id: ResourceId) {
|
||||
return `http://${get(address)}/thumbnail/${id}?token=${get(token)}`;
|
||||
const scheme = dev ? "http" : "https";
|
||||
return `${scheme}://${get(address)}/thumbnail/${id}?token=${get(token)}`;
|
||||
}
|
||||
|
||||
export function makeAudioUrl(id: TrackId) {
|
||||
return `http://${get(address)}/audio/external_id/${id}?token=${get(token)}`;
|
||||
const scheme = dev ? "http" : "https";
|
||||
return `${scheme}://${get(address)}/audio/external_id/${id}?token=${get(token)}`;
|
||||
}
|
||||
|
||||
export const currentTrack = writable<TrackWithId | null>(null);
|
||||
|
Loading…
Reference in New Issue
Block a user