diff --git a/apps/dcellar-web-ui/src/facade/common.ts b/apps/dcellar-web-ui/src/facade/common.ts index 0bfca5b4..38b4194c 100644 --- a/apps/dcellar-web-ui/src/facade/common.ts +++ b/apps/dcellar-web-ui/src/facade/common.ts @@ -77,7 +77,7 @@ export const getObjectInfoAndBucketQuota = async ({ export const getBnbUsdtExchangeRate = async (): Promise => { const [res, error] = await get({ - url: 'https://bsc-explorer-api.nodereal.io/api/token/getPrice?symbol=bnb', + url: '/api/bnb_price', customOptions: { needNotify: false }, }).then(resolve, commonFault); diff --git a/apps/dcellar-web-ui/src/pages/api/bnb_price/index.tsx b/apps/dcellar-web-ui/src/pages/api/bnb_price/index.tsx new file mode 100644 index 00000000..552feb2d --- /dev/null +++ b/apps/dcellar-web-ui/src/pages/api/bnb_price/index.tsx @@ -0,0 +1,15 @@ +import axios from 'axios'; +import { NextApiRequest, NextApiResponse } from 'next'; + +const handler = async (req: NextApiRequest, res: NextApiResponse) => { + const url = `https://bsc-explorer-api.nodereal.io/api/token/getPrice?symbol=bnb`; + try { + const { data } = await axios.get(url); + res.json(data); + } catch (e) { + console.error('bnb_price', e); + res.json({}); + } +}; + +export default handler;