From 5e827280e14336b0a4495c0634655b02adfd65c2 Mon Sep 17 00:00:00 2001 From: Deepak Sangle Date: Sat, 25 Nov 2023 07:53:12 +0530 Subject: [PATCH] added env for react --- web-client/package-lock.json | 33 ++++++++++++++++++++++++++------- web-client/package.json | 2 +- web-client/src/constant.js | 3 ++- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/web-client/package-lock.json b/web-client/package-lock.json index d2695a6..3e8b144 100644 --- a/web-client/package-lock.json +++ b/web-client/package-lock.json @@ -12,6 +12,7 @@ "@testing-library/react": "^13.3.0", "@testing-library/user-event": "^13.5.0", "axios": "^1.5.0", + "dotenv": "^16.3.1", "react": "^18.1.0", "react-dom": "^18.1.0", "react-router-dom": "^6.16.0", @@ -6386,11 +6387,14 @@ } }, "node_modules/dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", "engines": { - "node": ">=10" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" } }, "node_modules/dotenv-expand": { @@ -13780,6 +13784,14 @@ } } }, + "node_modules/react-scripts/node_modules/dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "engines": { + "node": ">=10" + } + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", @@ -20991,9 +21003,9 @@ } }, "dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==" }, "dotenv-expand": { "version": "5.1.0", @@ -26163,6 +26175,13 @@ "webpack-dev-server": "^4.6.0", "webpack-manifest-plugin": "^4.0.2", "workbox-webpack-plugin": "^6.4.1" + }, + "dependencies": { + "dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" + } } }, "read-cache": { diff --git a/web-client/package.json b/web-client/package.json index 0d988bf..4587fab 100644 --- a/web-client/package.json +++ b/web-client/package.json @@ -2,12 +2,12 @@ "name": "dear-diary", "version": "0.1.0", "private": true, - "proxy": "https://dear-diary-api.onrender.com", "dependencies": { "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^13.3.0", "@testing-library/user-event": "^13.5.0", "axios": "^1.5.0", + "dotenv": "^16.3.1", "react": "^18.1.0", "react-dom": "^18.1.0", "react-router-dom": "^6.16.0", diff --git a/web-client/src/constant.js b/web-client/src/constant.js index 4eea05f..87c3682 100644 --- a/web-client/src/constant.js +++ b/web-client/src/constant.js @@ -1,6 +1,7 @@ +const { REACT_APP_SERVER_URI, REACT_APP_LOCAL_ENV} = process.env const isDev = process.env.NODE_ENV === 'development' ; module.exports = { - BASE_URI : !isDev ? "https://dear-diary-api.onrender.com" : "http://localhost:5000" + BASE_URI : !isDev ? REACT_APP_SERVER_URI : REACT_APP_LOCAL_ENV } \ No newline at end of file