From b48d1ea745b75ed24f1bf4a51c023d33f4eaddeb Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Mon, 7 Mar 2022 23:09:30 -0800 Subject: [PATCH] add API_URl env var to client --- client/.env | 1 + client/next.config.js | 5 ++++- client/package.json | 1 + client/yarn.lock | 5 +++++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 client/.env diff --git a/client/.env b/client/.env new file mode 100644 index 00000000..98db62cf --- /dev/null +++ b/client/.env @@ -0,0 +1 @@ +API_URL=http://localhost:3000 \ No newline at end of file diff --git a/client/next.config.js b/client/next.config.js index ba7bb8b1..3aaadd88 100644 --- a/client/next.config.js +++ b/client/next.config.js @@ -1,3 +1,6 @@ +const dotenv = require("dotenv"); +dotenv.config(); + /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, @@ -8,7 +11,7 @@ const nextConfig = { return [ { source: "/api/:path*", - destination: "http://localhost:3000/:path*", + destination: `${process.env.API_URL}/:path*`, }, ]; }, diff --git a/client/package.json b/client/package.json index 572c42db..0ac88573 100644 --- a/client/package.json +++ b/client/package.json @@ -12,6 +12,7 @@ "@geist-ui/core": "^2.3.5", "@geist-ui/icons": "^1.0.1", "comlink": "^4.3.1", + "dotenv": "^16.0.0", "next": "12.1.0", "prismjs": "^1.27.0", "react": "17.0.2", diff --git a/client/yarn.lock b/client/yarn.lock index e3857502..dce2862d 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -537,6 +537,11 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" +dotenv@^16.0.0: + version "16.0.0" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.0.tgz#c619001253be89ebb638d027b609c75c26e47411" + integrity sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q== + emoji-regex@^9.2.2: version "9.2.2" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72"