Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fbfd20c965 | |||
| e781c6b04a |
@@ -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));
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user