diff --git a/.env.development b/.env.development new file mode 100644 index 0000000000000000000000000000000000000000..e53f5bcf1b18d9f3835a3424f6b9fd42e6c26dd8 --- /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 0000000000000000000000000000000000000000..ecc420b8d9a390d8fd7bdd4d25f63b237f33ae6d --- /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 a49860274be303ac4b6b40f2a2cd607d14d30951..6c3d4ef54838434da3a546eee6b3f576635d551a 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 af7c65ba6d5b9bacb635138ac7b953cc0ba56366..6db47a486bcb1c92cd4fbea8d9baebdd2d0f537b 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 0465331a772c5edffcb9871e1025882867ced541..a78d1d4c3a7b65fb2583d15f32d51e4b748004bb 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';