From bc7de876d2f460efb1b67e4239790e79ea21abe5 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Tue, 26 Jan 2021 10:54:36 +0100 Subject: [PATCH] use public URL in the react app --- src/config/front.js | 1 - src/front/pages/login/github.jsx | 2 +- src/front/services/api.jsx | 10 +++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/config/front.js b/src/config/front.js index 5a138fa..5a25f6c 100644 --- a/src/config/front.js +++ b/src/config/front.js @@ -1,7 +1,6 @@ module.exports = ` window._env_ = { "PUBLIC_URL": "${process.env.PUBLIC_URL || ''}", - "API_URL": "${process.env.API_URL}", "GITHUB_CLIENT_ID": "${process.env.GITHUB_CLIENT_ID}", } `; diff --git a/src/front/pages/login/github.jsx b/src/front/pages/login/github.jsx index 817ffeb..5e136a4 100644 --- a/src/front/pages/login/github.jsx +++ b/src/front/pages/login/github.jsx @@ -15,7 +15,7 @@ class Github extends React.Component { const { location, history } = this.props; const params = new URLSearchParams(location.search); - const responses = await fetch(`${window._env_.API_URL}/api/auth`, { + const responses = await fetch(`${window._env_.PUBLIC_URL}/api/auth`, { headers: { Accept: 'application/json', 'Content-Type': 'application/json', diff --git a/src/front/services/api.jsx b/src/front/services/api.jsx index 3159ffb..19da006 100644 --- a/src/front/services/api.jsx +++ b/src/front/services/api.jsx @@ -24,7 +24,7 @@ export const listOfApplications = async () => { return []; } - const responses = await fetch(`${window._env_.API_URL}/api/application`, { + const responses = await fetch(`${window._env_.PUBLIC_URL}/api/application`, { headers, method: 'GET', }); @@ -41,7 +41,7 @@ export const getApplication = async (appId) => { } const responses = await fetch( - `${window._env_.API_URL}/api/application/${appId}`, + `${window._env_.PUBLIC_URL}/api/application/${appId}`, { headers, method: 'GET', @@ -59,7 +59,7 @@ export const createApplication = async (newApplication) => { return {}; } - const responses = await fetch(`${window._env_.API_URL}/api/application`, { + const responses = await fetch(`${window._env_.PUBLIC_URL}/api/application`, { headers, method: 'POST', body: JSON.stringify(newApplication), @@ -78,7 +78,7 @@ export const updateApplication = async (appId, application) => { } const responses = await fetch( - `${window._env_.API_URL}/api/application/${appId}`, + `${window._env_.PUBLIC_URL}/api/application/${appId}`, { headers, method: 'PUT', @@ -98,7 +98,7 @@ export const deleteUser = async () => { return {}; } - const responses = await fetch(`${window._env_.API_URL}/api/developer`, { + const responses = await fetch(`${window._env_.PUBLIC_URL}/api/developer`, { headers, method: 'DELETE', });