From 93b5ea20ca590996f6dc90713a76800180d0621c Mon Sep 17 00:00:00 2001 From: Danshil Kokil Mungur Date: Wed, 8 Dec 2021 04:38:17 +0400 Subject: [PATCH] fix(servarr): handle baseurl error when testing connection (#2294) * fix(servarr): handle base url error when testing servarr connection * fix(servarr): suggested changes --- server/routes/settings/radarr.ts | 10 +++++----- server/routes/settings/sonarr.ts | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/server/routes/settings/radarr.ts b/server/routes/settings/radarr.ts index fd5791c5a..a33bfcdba 100644 --- a/server/routes/settings/radarr.ts +++ b/server/routes/settings/radarr.ts @@ -46,7 +46,10 @@ radarrRoutes.post< url: RadarrAPI.buildUrl(req.body, '/api/v3'), }); - const { urlBase } = await radarr.getSystemStatus(); + const urlBase = await radarr + .getSystemStatus() + .then((value) => value.urlBase) + .catch(() => req.body.baseUrl); const profiles = await radarr.getProfiles(); const folders = await radarr.getRootFolders(); const tags = await radarr.getTags(); @@ -58,10 +61,7 @@ radarrRoutes.post< path: folder.path, })), tags, - urlBase: - req.body.baseUrl && req.body.baseUrl !== '/' - ? req.body.baseUrl - : urlBase, + urlBase, }); } catch (e) { logger.error('Failed to test Radarr', { diff --git a/server/routes/settings/sonarr.ts b/server/routes/settings/sonarr.ts index 09baabd95..da5a5bb3f 100644 --- a/server/routes/settings/sonarr.ts +++ b/server/routes/settings/sonarr.ts @@ -42,7 +42,10 @@ sonarrRoutes.post('/test', async (req, res, next) => { url: SonarrAPI.buildUrl(req.body, '/api/v3'), }); - const { urlBase } = await sonarr.getSystemStatus(); + const urlBase = await sonarr + .getSystemStatus() + .then((value) => value.urlBase) + .catch(() => req.body.baseUrl); const profiles = await sonarr.getProfiles(); const folders = await sonarr.getRootFolders(); const languageProfiles = await sonarr.getLanguageProfiles(); @@ -56,10 +59,7 @@ sonarrRoutes.post('/test', async (req, res, next) => { })), languageProfiles, tags, - urlBase: - req.body.baseUrl && req.body.baseUrl !== '/' - ? req.body.baseUrl - : urlBase, + urlBase, }); } catch (e) { logger.error('Failed to test Sonarr', {