conditional base url for prod and dev

This commit is contained in:
Owen Rees
2023-06-12 16:56:51 +02:00
parent 8e421e5d11
commit ec60b6be91
+4 -1
View File
@@ -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();