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.