env variables changes

This commit is contained in:
Owen Rees
2023-06-12 20:47:58 +02:00
parent ec60b6be91
commit d8e12c48af
2 changed files with 10 additions and 5 deletions
+9 -4
View File
@@ -3,11 +3,16 @@
* @remarks The result is cached for the revalidation period in seconds
*/
export default async function getTournaments(country: string) {
const baseUrl = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: "http://localhost:3000";
const baseUrl =
process.env.NODE_ENV === "production"
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
: "http://localhost:3000";
const res = await fetch(`${baseUrl}/api/tournaments/${country}`, {
next: { revalidate: 300 },
});
return await res.json();
if (res.status !== 200) {
throw new Error("Failed to fetch tournament data");
}
return res.json();
}