fix(api): detect Riot TFT paths without a leading slash
continuous-integration/drone/push Build was killed
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:
1 parent
1583b7035f
commit
737c69e5c8
1 file changed
+8
-3
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user