mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2025-12-24 02:39:18 -05:00
refactor: resolving PR comments
Reverting get() baseUrl overwrite in favour of a vanilla fetch() call #943
This commit is contained in:
@@ -176,24 +176,33 @@ class EmbyConnectAPI extends ExternalAPI {
|
||||
deviceId?: string
|
||||
): Promise<LocalUserAuthExchangeResponse> {
|
||||
try {
|
||||
return this.get(
|
||||
'/emby/Connect/Exchange',
|
||||
const params = new URLSearchParams({
|
||||
format: 'json',
|
||||
ConnectUserId: userId,
|
||||
'X-Emby-Client': 'Jellyseerr',
|
||||
'X-Emby-Device-Id': deviceId ?? uniqueId(),
|
||||
'X-Emby-Client-Version': getAppVersion(),
|
||||
'X-Emby-Device-Name': 'Jellyseerr',
|
||||
'X-Emby-Token': accessKey,
|
||||
});
|
||||
|
||||
const response = await fetch(
|
||||
`${getHostname()}/emby/Connect/Exchange?${params}`,
|
||||
{
|
||||
format: 'json',
|
||||
ConnectUserId: userId,
|
||||
'X-Emby-Client': 'Jellyseerr',
|
||||
'X-Emby-Device-Id': deviceId ?? uniqueId(),
|
||||
'X-Emby-Client-Version': getAppVersion(),
|
||||
'X-Emby-Device-Name': 'Jellyseerr',
|
||||
'X-Emby-Token': accessKey,
|
||||
},
|
||||
undefined,
|
||||
{},
|
||||
getHostname()
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(response.statusText, { cause: response });
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
} catch (e) {
|
||||
logger.debug('Failed local user auth exchange');
|
||||
throw new ApiError(e.cause?.status, ApiErrorCode.InvalidCredentials);
|
||||
throw new ApiError(e.cause?.status, ApiErrorCode.InvalidAuthToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,7 @@ class ExternalAPI {
|
||||
endpoint: string,
|
||||
params?: Record<string, string>,
|
||||
ttl?: number,
|
||||
config?: RequestInit,
|
||||
overwriteBaseUrl?: string
|
||||
config?: RequestInit
|
||||
): Promise<T> {
|
||||
const cacheKey = this.serializeCacheKey(endpoint, {
|
||||
...this.params,
|
||||
@@ -59,7 +58,7 @@ class ExternalAPI {
|
||||
return cachedItem;
|
||||
}
|
||||
|
||||
const url = this.formatUrl(endpoint, params, overwriteBaseUrl);
|
||||
const url = this.formatUrl(endpoint, params);
|
||||
const response = await this.fetch(url, {
|
||||
...config,
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user