fix(api): detect Riot TFT paths without a leading slash
continuous-integration/drone/push Build was killed

Proxy rest paths are tft/league/... so includes('/tft/') never matched
and the LOL key (missing) was used instead.
This commit is contained in:
miczek committed 2026-10-15 05:32:28 +03:00
1 parent 1583b7035f
commit 737c69e5c8
1 file changed
+8 -3
+8 -3
View File
@@ -26,10 +26,15 @@ const TRACKER_API_BASE = 'https://public-api.tracker.gg';
function getRiotApiKey(path: string, gameTypeHeader: string | undefined): string { function getRiotApiKey(path: string, gameTypeHeader: string | undefined): string {
const lolKey = process.env['RIOT_API_KEY_LOL'] || ''; const lolKey = process.env['RIOT_API_KEY_LOL'] || '';
const tftKey = process.env['RIOT_API_KEY_TFT'] || ''; const tftKey = process.env['RIOT_API_KEY_TFT'] || '';
if (gameTypeHeader === 'tft' || path.includes('/tft/')) { // rest path is like "tft/league/..." (no leading slash) after the routing region.
return tftKey; 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. // The Express app is exported so that it can be used by serverless Functions.