From 2908c9edf0e9ca4bb53884d7cc5e79dcc6b50098 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 16 Nov 2019 21:10:39 +0000 Subject: [PATCH 1/3] test for existence of REACT_APP_CUSTOM_API_URL, use that if it exists, else fallback to PUBLIC_URL Signed-off-by: Adam Warner --- src/config.development.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/config.development.tsx b/src/config.development.tsx index d9e4d4f..cfb2df9 100644 --- a/src/config.development.tsx +++ b/src/config.development.tsx @@ -10,8 +10,17 @@ import { Config } from "./config"; +let apiUrlBase; + +if (process.env.REACT_APP_CUSTOM_API_URL) { + apiUrlBase = process.env.REACT_APP_CUSTOM_API_URL; +} +else { + apiUrlBase = process.env.PUBLIC_URL; +} + export default { developmentMode: true, fakeAPI: false, - apiPath: process.env.PUBLIC_URL + "/api" + apiPath: apiUrlBase + "/api" } as Config; From c644bb9c1bb910151cd5667cd3348eb7500ad163 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 16 Nov 2019 21:29:59 +0000 Subject: [PATCH 2/3] format to prettier's liking. Signed-off-by: Adam Warner --- src/config.development.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/config.development.tsx b/src/config.development.tsx index cfb2df9..2bedaad 100644 --- a/src/config.development.tsx +++ b/src/config.development.tsx @@ -14,8 +14,7 @@ let apiUrlBase; if (process.env.REACT_APP_CUSTOM_API_URL) { apiUrlBase = process.env.REACT_APP_CUSTOM_API_URL; -} -else { +} else { apiUrlBase = process.env.PUBLIC_URL; } From 045014ba6f55eb04ba7da65ea2328e8d7aaa3802 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 16 Nov 2019 21:43:20 +0000 Subject: [PATCH 3/3] apply @mcat12's suggestion. I agree, it is cleaner to read! Signed-off-by: Adam Warner --- src/config.development.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/config.development.tsx b/src/config.development.tsx index 2bedaad..61b835e 100644 --- a/src/config.development.tsx +++ b/src/config.development.tsx @@ -10,13 +10,8 @@ import { Config } from "./config"; -let apiUrlBase; - -if (process.env.REACT_APP_CUSTOM_API_URL) { - apiUrlBase = process.env.REACT_APP_CUSTOM_API_URL; -} else { - apiUrlBase = process.env.PUBLIC_URL; -} +const apiUrlBase = + process.env.REACT_APP_CUSTOM_API_URL || process.env.PUBLIC_URL; export default { developmentMode: true,