diff --git a/apps/api/src/middlewares/rateLimiter.ts b/apps/api/src/middlewares/rateLimiter.ts index 58abc4f0f..a2ddda418 100644 --- a/apps/api/src/middlewares/rateLimiter.ts +++ b/apps/api/src/middlewares/rateLimiter.ts @@ -35,14 +35,8 @@ const FREE_PLAN: Plan = { title: 'Free Plan', }; const KITWALLET_PATH = '/v1/kitwallet'; -const LEGACY_PATH = '/v1/legacy'; -const SUBNETS = [ - '10.0.0.0/8', - '172.16.0.0/12', - '192.168.0.0/16', - '193.70.74.48/32', -]; +const SUBNETS = ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16']; const rateLimiter = catchAsync( async (req: Request, res: Response, next: NextFunction) => { @@ -62,11 +56,6 @@ const rateLimiter = catchAsync( const authHeader = req.headers.authorization || ''; const token = authHeader.replace('Bearer ', ''); - if (req.baseUrl === LEGACY_PATH) { - logger.info('LEGACY_PATH'); - return next(); - } - if (config.apiAccessKey && token === config.apiAccessKey) { return next(); } diff --git a/apps/explorer-selector/next.config.js b/apps/explorer-selector/next.config.js index 72b5ecd49..825e3fd25 100644 --- a/apps/explorer-selector/next.config.js +++ b/apps/explorer-selector/next.config.js @@ -6,7 +6,7 @@ const network = env('NEXT_PUBLIC_NETWORK_ID'); const mainnetApiUrl = env('NEXT_PUBLIC_MAINNET_API_URL') || 'https://api.nearblocks.io/v1'; const testnetApiUrl = - env('NEXT_PUBLIC_TESTNET_API_URL') || 'https://api.nearblocks.io/v1'; + env('NEXT_PUBLIC_TESTNET_API_URL') || 'https://api-testnet.nearblocks.io/v1'; configureRuntimeEnv(); /** @type {import('next').NextConfig} */ @@ -32,6 +32,7 @@ const nextConfig = { ? `${mainnetApiUrl}/node/telemetry` : `${testnetApiUrl}/node/telemetry`, }, + /* { source: '/api/circulating-supply', destination: @@ -39,6 +40,7 @@ const nextConfig = { ? `${mainnetApiUrl}/legacy/circulating-supply` : `${testnetApiUrl}/legacy/circulating-supply`, }, +*/ { source: '/api/circulating-supply-in-near', destination: diff --git a/apps/explorer-selector/src/pages/api/circulating-supply.tsx b/apps/explorer-selector/src/pages/api/circulating-supply.tsx new file mode 100644 index 000000000..359bb830a --- /dev/null +++ b/apps/explorer-selector/src/pages/api/circulating-supply.tsx @@ -0,0 +1,35 @@ +import type { NextApiRequest, NextApiResponse } from 'next'; + +export default async function handler( + _req: NextApiRequest, + res: NextApiResponse +) { + const apiKey = process.env.API_ACCESS_KEY; + const network = process.env.NEXT_PUBLIC_NETWORK_ID; + const mainnetApiUrl = 'https://api.nearblocks.io/v1'; + const testnetApiUrl = 'https://api-testnet.nearblocks.io/v1'; + + const url = + network === 'mainnet' + ? `${mainnetApiUrl}/legacy/circulating-supply` + : `${testnetApiUrl}/legacy/circulating-supply`; + + try { + const response = await fetch(url, { + method: 'GET', + headers: { + Authorization: `Bearer ${apiKey}`, + 'Content-Type': 'application/json', + }, + }); + + if (!response.ok) { + throw new Error('Failed to fetch data'); + } + + const data = await response.json(); + res.status(200).json(data); + } catch (error) { + res.status(500).json({ error: 'Failed to fetch circulating supply data' }); + } +}