From 25fbd5834943c381d73d4074d172bc7e64c6f69e Mon Sep 17 00:00:00 2001
From: Imre Toth <imre.toth@ess.eu>
Date: Fri, 7 May 2021 09:25:34 +0200
Subject: [PATCH] ICSHWI-6976: added proxy to the dev settings; externalised
 server address

---
 .env.development      | 2 ++
 .env.test             | 2 ++
 .gitignore            | 1 +
 package.json          | 1 +
 src/api/SwaggerApi.js | 4 ++--
 5 files changed, 8 insertions(+), 2 deletions(-)
 create mode 100644 .env.development
 create mode 100644 .env.test

diff --git a/.env.development b/.env.development
new file mode 100644
index 00000000..e53f5bcf
--- /dev/null
+++ b/.env.development
@@ -0,0 +1,2 @@
+REACT_APP_SERVER_ADDRESS=
+REACT_APP_API_BASE_ENDPOINT=/ccce-api
\ No newline at end of file
diff --git a/.env.test b/.env.test
new file mode 100644
index 00000000..ecc420b8
--- /dev/null
+++ b/.env.test
@@ -0,0 +1,2 @@
+REACT_APP_SERVER_ADDRESS=http://localhost:8080
+REACT_APP_API_BASE_ENDPOINT=/ccce-api
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index a4986027..6c3d4ef5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,4 @@ yarn-error.log*
 
 .eslintcache
 /package-lock.json
+.vscode
diff --git a/package.json b/package.json
index af7c65ba..6db47a48 100644
--- a/package.json
+++ b/package.json
@@ -2,6 +2,7 @@
   "name": "ccdb-ui-prototype",
   "version": "0.1.0",
   "private": true,
+  "proxy": "http://localhost:8080",
   "dependencies": {
     "@fontsource/roboto": "^4.1.0",
     "@material-ui/core": "^4.11.2",
diff --git a/src/api/SwaggerApi.js b/src/api/SwaggerApi.js
index 0465331a..a78d1d4c 100644
--- a/src/api/SwaggerApi.js
+++ b/src/api/SwaggerApi.js
@@ -5,11 +5,11 @@ import { useSnackbar } from 'notistack';
 import { useHistory } from 'react-router';
 
 
-const SERVER = `https://${window.location.hostname}/api`; // current domain
+const SERVER = `${process.env.REACT_APP_SERVER_ADDRESS}`; // current domain
 
 const createSwaggerClient = async () => {
   const swaggerOptions = {
-    url: `${SERVER}/ccce-api`,
+    url: `${SERVER}${process.env.REACT_APP_API_BASE_ENDPOINT}`,
     requestInterceptor: (req) => {
       // if (user) req.headers["Authorization"] = `Bearer ${user.token}`;
       req.headers['Content-Type'] = 'application/json';
-- 
GitLab