Skip to content

Commit

Permalink
fix: env var
Browse files Browse the repository at this point in the history
  • Loading branch information
ddecrulle committed Dec 23, 2022
1 parent ec44b28 commit 595f2d5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "knowledge",
"version": "1.3.2",
"version": "1.3.3",
"description": "The user interface that presents the service offer of the INSEE survey information system",
"author": "u/ddecrulle",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions public/env-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
if (!window._env_) window._env_ = {};
49 changes: 25 additions & 24 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<link href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,700i,900,900i" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--

<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<link href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,700i,900,900i" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -27,12 +25,14 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Knowledge</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
<script src="%PUBLIC_URL%/env-config.js"></script>
<title>Knowledge</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand All @@ -42,5 +42,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</body>

</html>
2 changes: 1 addition & 1 deletion src/core/env.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const getEnvVar = (key) =>
window?._env_?.key || process.env[`REACT_APP_${key}`];
window?._env_?.[key] || process.env[`REACT_APP_${key}`];
1 change: 0 additions & 1 deletion src/ui/coreApi/coreProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export function CoreProvider({ children }) {
const apiUrl = getEnvVar('API_URL');
const apiClient = apiUrl ? createApiClient(apiUrl) : createMockApiClient();

console.log(apiUrl);
return (
<CoreApiContext.Provider value={apiClient}>
{children}
Expand Down

0 comments on commit 595f2d5

Please sign in to comment.