Skip to content

Commit

Permalink
Remove all hard coded env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbeaird committed Aug 27, 2020
1 parent 07dde5a commit afe32ae
Show file tree
Hide file tree
Showing 10 changed files with 1,788 additions and 41 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ client/.env
/.idea
test.db
globalConfig.json
videos/
videos/
screenshots/
6 changes: 2 additions & 4 deletions backend/config/database.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
exports.PORT = process.env.PORT || 4000;
exports.DATABASE_URL = process.env.DATABASE_URL || 'mongodb://localhost:27017/testdb';
exports.TEST_DATABASE_URL = process.env.TEST_DATABASE_URL || 'mongodb://localhost:27017/testdb';
exports.LIVE_DATABASE_URL = process.env.LIVE_DATABASE_URL || 'mongodb://localhost:27017/testdb';
exports.PORT = process.env.BACKEND_PORT;
exports.DATABASE_URL = process.env.DATABASE_URL;
3 changes: 1 addition & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@
},
"jest": {
"testEnvironment": "node"
},
"proxy": "http://localhost:3000/"
}
}
7 changes: 5 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
"dependencies": {
"@babel/plugin-transform-react-jsx-self": "^7.10.4",
"classnames": "^2.2.6",
"cross-env": "^7.0.2",
"cross-var": "^1.1.0",
"d3": "^5.15.1",
"dotenv-cli": "^3.2.0",
"firebase": "^7.15.1",
"http-proxy-middleware": "^1.0.5",
"local-storage": "^2.0.0",
"mathjs": "^6.6.2",
"minimist": "^1.2.3",
Expand All @@ -20,7 +24,7 @@
"react-scripts": "^3.4.1"
},
"scripts": {
"start": "react-scripts start",
"start": "dotenv -e .env -- cross-var cross-env PORT=%CLIENT_PORT% react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --watchAll=false",
"test:watch": "react-scripts test",
Expand All @@ -30,7 +34,6 @@
"eslintConfig": {
"extends": "react-app"
},
"proxy": "http://localhost:4000/",
"browserslist": {
"production": [
">0.2%",
Expand Down
10 changes: 10 additions & 0 deletions client/src/setupProxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { createProxyMiddleware } = require("http-proxy-middleware");
module.exports = function (app) {
app.use(
"/api",
createProxyMiddleware({
target: process.env.REACT_APP_PROXY,
changeOrigin: true,
})
);
};
Loading

0 comments on commit afe32ae

Please sign in to comment.