Skip to content

Commit e01eef9

Browse files
authored
Merge pull request #21 from topcoderinc/dev
Dev
2 parents 538079f + f7bc500 commit e01eef9

File tree

4 files changed

+43
-7
lines changed

4 files changed

+43
-7
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,35 @@
11
react-app
22
---
33

4+
# Local Deployment
5+
Copy `envSample` as `.env`.
46
Install node dependencies using `npm install`
57
Run the development server using `npm run start`
68

7-
The react app is deployed to heroku `https://react-app-drones-spanhawk.herokuapp.com`
9+
10+
# Local Configuration Variables
11+
You can edit them in `.env` file.
12+
13+
# Heroku Deployment
14+
```
15+
git init
16+
git add .
17+
git commit -m "react-create-app on Heroku"
18+
# make sure commit all codes and usuaully you do not need to run above command if you are sure your codes in git repo is latest.
19+
heroku create -b https://github.com/mars/create-react-app-buildpack.git
20+
# set variables defined in .env
21+
heroku config:set REACT_APP_API_BASE_PATH=base url
22+
heroku config:set REACT_APP_SOCKET_URL=socket url
23+
heroku config:set REACT_APP_AUTH0_CLIEND_ID=auth0 client id
24+
heroku config:set REACT_APP_AUTH0_DOMAIN=auth0 domain
25+
heroku config:set REACT_APP_GOOGLE_API_KEY=google api key
26+
git push heroku HEAD:master
27+
heroku open
28+
```
29+
30+
You can use new configuration with below commands from [set-vars-on-heroku](https://github.com/mars/create-react-app-buildpack#set-vars-on-heroku).
31+
```
32+
heroku config:set REACT_APP_API_BASE_PATH=new base url
33+
git commit --allow-empty -m "Set REACT_APP_API_BASE_PATH config var"
34+
git push heroku HEAD:master
35+
```

envSample

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
REACT_APP_API_BASE_PATH=https://kb-dsp-server.herokuapp.com
2+
REACT_APP_SOCKET_URL=https://kb-dsp-server.herokuapp.com
3+
REACT_APP_AUTH0_CLIEND_ID=XXXXzjS2nVSqHxHHE64RhvvKY6e0TYpK
4+
REACT_APP_AUTH0_DOMAIN=dronetest.auth0.com
5+
REACT_APP_GOOGLE_API_KEY=XXXXSyCR3jfBdv9prCBYBOf-fPUDhjPP4K05YjE

src/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @author TCSCODER
1010
* @version 1.0.0
1111
*/
12-
12+
import config from './config';
1313
import React, { Component } from 'react';
1414
import './styles/App.css';
1515
import scriptLoader from 'react-async-script-loader';
@@ -83,5 +83,5 @@ class App extends Component {
8383
}
8484

8585
export default scriptLoader(
86-
['https://maps.googleapis.com/maps/api/js?key=AIzaSyCR3jfBdv9prCBYBOf-fPUDhjPP4K05YjE', 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js']
86+
[`https://maps.googleapis.com/maps/api/js?key=${config.google.apiKey}`, 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js']
8787
)(App);

src/config/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@
1111

1212
const config = {
1313
api: {
14-
basePath: 'https://kb-dsp-server.herokuapp.com',
14+
basePath: process.env.REACT_APP_API_BASE_PATH,
1515
},
1616
socket: {
17-
url: 'https://kb-dsp-server.herokuapp.com',
17+
url: process.env.REACT_APP_SOCKET_URL,
1818
},
19-
AUTH0_CLIEND_ID: '3CGKzjS2nVSqHxHHE64RhvvKY6e0TYpK',
20-
AUTH0_DOMAIN: 'dronetest.auth0.com',
19+
google: {
20+
apiKey: process.env.REACT_APP_GOOGLE_API_KEY
21+
},
22+
AUTH0_CLIEND_ID: process.env.REACT_APP_AUTH0_CLIEND_ID,
23+
AUTH0_DOMAIN: process.env.REACT_APP_AUTH0_DOMAIN,
2124
};
2225

2326
export default config;

0 commit comments

Comments
 (0)