From 06c7cd01b39823d3020b4766a0514df38ab93209 Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Mon, 10 Jan 2022 02:13:00 +0000 Subject: [PATCH] dotenv config --- .env.development | 4 ++++ .env.production | 4 ++++ .env.test | 1 + README.md | 4 ++++ public/index.html | 2 +- src/config.js | 18 ++++++++++++++++++ 6 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 .env.development create mode 100644 .env.production create mode 120000 .env.test create mode 100644 src/config.js diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..af56fe2 --- /dev/null +++ b/.env.development @@ -0,0 +1,4 @@ +PUBLIC_URL=http://localhost:3000 +API_URL=http://localhost:8080 + +REACT_APP_WEBSITE_NAME="RetroPilot Connect - Development" diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..aec8c58 --- /dev/null +++ b/.env.production @@ -0,0 +1,4 @@ +PUBLIC_URL=https://connect.retropilot.org +API_URL=https://api.retropilot.org + +REACT_APP_WEBSITE_NAME="RetroPilot Connect" diff --git a/.env.test b/.env.test new file mode 120000 index 0000000..4a61ec7 --- /dev/null +++ b/.env.test @@ -0,0 +1 @@ +.env.development \ No newline at end of file diff --git a/README.md b/README.md index 94d896f..eadbcbc 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,7 @@ React client for Retropilot Ties into https://github.com/retropilot/retropilot-server/ to provide a react frontend + +To override the environment variables, create a `.env.local` file. You can also override the +variables for development, testing and production independently (`.env.development`, +`.env.test.local` and `.env.production.local` files). diff --git a/public/index.html b/public/index.html index 8a3bb88..319b5e4 100644 --- a/public/index.html +++ b/public/index.html @@ -24,7 +24,7 @@ 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`. --> - RetroPilot Client + %REACT_APP_WEBSITE_NAME% diff --git a/src/config.js b/src/config.js new file mode 100644 index 0000000..487e1a7 --- /dev/null +++ b/src/config.js @@ -0,0 +1,18 @@ +const config = { + /** + * The address at which the website is hosted. + */ + publicUrl: process.env.PUBLIC_URL, + + /** + * The address at which the API is accessible. + */ + apiUrl: process.env.API_URL, + + /** + * The name displayed in the website title. + */ + websiteName: process.env.REACT_APP_WEBSITE_NAME, +}; + +export default config;