From d8a70d5a636a39f3afd9bd07949d0c0915a2b3b9 Mon Sep 17 00:00:00 2001 From: Owen Rees Date: Tue, 13 Jun 2023 09:47:58 +0200 Subject: [PATCH] env --- .env | 1 + next.config.js | 6 +----- utils/getTournamentData.tsx | 5 ++++- 3 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..7cca59e --- /dev/null +++ b/.env @@ -0,0 +1 @@ +NEXT_PUBLIC_HOSTNAME = "https://echecsfrance.vercel.app" diff --git a/next.config.js b/next.config.js index 95db3ce..658404a 100644 --- a/next.config.js +++ b/next.config.js @@ -1,8 +1,4 @@ /** @type {import('next').NextConfig} */ -const nextConfig = { - env: { - SERVER: process.env.SERVER, - }, -}; +const nextConfig = {}; module.exports = nextConfig; diff --git a/utils/getTournamentData.tsx b/utils/getTournamentData.tsx index d8ca246..62b0437 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 server = process.env.SERVER; + const server = + process.env.NODE_ENV === "production" + ? process.env.NEXT_PUBLIC_HOSTNAME + : "http://localhost:3000"; const res = await fetch(`${server}/api/tournaments/${country}`, { next: { revalidate: 300 },