From e555354e179901ff29f651bb949055cf1ff633f3 Mon Sep 17 00:00:00 2001 From: William Oldham Date: Sun, 3 Mar 2024 18:36:12 +0000 Subject: [PATCH] If TMDB key is empty, don't attempt request --- src/backend/metadata/tmdb.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/metadata/tmdb.ts b/src/backend/metadata/tmdb.ts index 2bae75d1..b143b312 100644 --- a/src/backend/metadata/tmdb.ts +++ b/src/backend/metadata/tmdb.ts @@ -144,12 +144,16 @@ export function decodeTMDBId( const baseURL = "https://api.themoviedb.org/3"; +const apiKey = conf().TMDB_READ_API_KEY; + const headers = { accept: "application/json", - Authorization: `Bearer ${conf().TMDB_READ_API_KEY}`, + Authorization: `Bearer ${apiKey}`, }; async function get(url: string, params?: object): Promise { + if (!apiKey) throw new Error("TMDB API key not set"); + const res = await mwFetch(encodeURI(url), { headers, baseURL,