Skip to content

Commit

Permalink
fix: api call + env (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
colbr authored Jan 16, 2024
1 parent d6bfbdb commit 3f5d0ea
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ export const StakingZApp = ({ provider, web3 }: AppProps) => {
* we're moving fast and need a quick fix.
*/

const SUPABASE_URL =
import.meta.env.VITE_STAKING_SUPABASE_URL ??
process.env.REACT_APP_STAKING_SUPABASE_URL;
const SUPABASE_URL = 'https://mrjliccblgblgtyqdbgz.supabase.co';

if (!SUPABASE_URL) {
throw new Error(
Expand All @@ -69,15 +67,14 @@ const { fetch: originalFetch } = window;
window.fetch = async (...args) => {
let [resource, config] = args;

const url = resource.toString();
const url = new URL(resource.toString());

if (url.startsWith('https://api.coingecko.com:443/')) {
resource = new URL(
url.replace(
'https://api.coingecko.com:443/',
SUPABASE_URL + '/functions/v1/price/',
),
);
if (
url.hostname === 'api.coingecko.com' &&
(url.pathname.includes('/coins/wilder-world') ||
url.pathname.includes('/coins/ethereum'))
) {
resource = new URL('/functions/v1/price' + url.pathname, SUPABASE_URL);
}

return await originalFetch(resource, config);
Expand Down

0 comments on commit 3f5d0ea

Please sign in to comment.