2 Commits
1.8 ... 1.82

Author SHA1 Message Date
fbfd20c965 invidiousAPI: handle slashes 2025-02-22 02:04:05 -08:00
e781c6b04a player: websockets ssl 2025-02-22 01:27:08 -08:00
3 changed files with 5 additions and 3 deletions

View File

@@ -109,7 +109,8 @@ export const API = {
},
subscribeToEvents(onMessage: (event: any) => void): WebSocket {
const ws = new WebSocket(`ws://${window.location.host}/api/events`);
const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
const ws = new WebSocket(`${protocol}://${window.location.host}/api/events`);
ws.onmessage = (event) => {
onMessage(JSON.parse(event.data));
};

View File

@@ -32,7 +32,7 @@ export const getInvidiousSearchURL = (query: string): string =>
`${INVIDIOUS_API_ENDPOINT}/search?q=${encodeURIComponent(query)}`;
export const getInvidiousThumbnailURL = (url: string): string =>
`${INVIDIOUS_BASE_URL}${url}`;
`${INVIDIOUS_BASE_URL}/${url}`;
const preferredThumbnailAPIURL = (thumbnails: InvidiousVideoThumbnail[] | undefined): string => {
if (!thumbnails || thumbnails.length === 0) {

View File

@@ -118,7 +118,8 @@ apiRouter.get("/thumbnail", withErrorHandling(async (req, res) => {
}
try {
const response = await fetch(getInvidiousThumbnailURL(thumbnailUrl));
const thumbnailUrlWithoutLeadingSlash = thumbnailUrl.startsWith('/') ? thumbnailUrl.slice(1) : thumbnailUrl;
const response = await fetch(getInvidiousThumbnailURL(thumbnailUrlWithoutLeadingSlash));
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}