From 737c69e5c836baa7b7deae007d9580942e87155e Mon Sep 17 00:00:00 2001 From: miczek Date: Thu, 15 Oct 2026 05:32:28 +0300 Subject: [PATCH] fix(api): detect Riot TFT paths without a leading slash Proxy rest paths are tft/league/... so includes('/tft/') never matched and the LOL key (missing) was used instead. --- server.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server.ts b/server.ts index b4bb50a..7747260 100644 --- a/server.ts +++ b/server.ts @@ -26,10 +26,15 @@ const TRACKER_API_BASE = 'https://public-api.tracker.gg'; function getRiotApiKey(path: string, gameTypeHeader: string | undefined): string { const lolKey = process.env['RIOT_API_KEY_LOL'] || ''; const tftKey = process.env['RIOT_API_KEY_TFT'] || ''; - if (gameTypeHeader === 'tft' || path.includes('/tft/')) { - return tftKey; + // rest path is like "tft/league/..." (no leading slash) after the routing region. + const isTft = + gameTypeHeader === 'tft' || + path.startsWith('tft/') || + path.includes('/tft/'); + if (isTft) { + return tftKey || lolKey; } - return lolKey; + return lolKey || tftKey; } // The Express app is exported so that it can be used by serverless Functions.