From ec60b6be91100e1592cdc41ecdc25e40ad36bcd0 Mon Sep 17 00:00:00 2001 From: Owen Rees Date: Mon, 12 Jun 2023 16:56:51 +0200 Subject: [PATCH] conditional base url for prod and dev --- utils/getTournamentData.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/getTournamentData.tsx b/utils/getTournamentData.tsx index 7721817..4048d3f 100644 --- a/utils/getTournamentData.tsx +++ b/utils/getTournamentData.tsx @@ -3,7 +3,10 @@ * @remarks The result is cached for the revalidation period in seconds */ export default async function getTournaments(country: string) { - const res = await fetch(`http://localhost:3000/api/tournaments/${country}`, { + const baseUrl = process.env.VERCEL_URL + ? `https://${process.env.VERCEL_URL}` + : "http://localhost:3000"; + const res = await fetch(`${baseUrl}/api/tournaments/${country}`, { next: { revalidate: 300 }, }); return await res.json();