Skip to content

Commit 2ff4e30

Browse files
committed
deploy heroku
1 parent 932a54d commit 2ff4e30

File tree

4 files changed

+102
-10949
lines changed

4 files changed

+102
-10949
lines changed

README.md

Lines changed: 50 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,51 @@
1-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
21

3-
## Available Scripts
4-
5-
In the project directory, you can run:
6-
7-
### `yarn start`
8-
9-
Runs the app in the development mode.<br />
10-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11-
12-
The page will reload if you make edits.<br />
13-
You will also see any lint errors in the console.
14-
15-
### `yarn test`
16-
17-
Launches the test runner in the interactive watch mode.<br />
18-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19-
20-
### `yarn build`
21-
22-
Builds the app for production to the `build` folder.<br />
23-
It correctly bundles React in production mode and optimizes the build for the best performance.
24-
25-
The build is minified and the filenames include the hashes.<br />
26-
Your app is ready to be deployed!
27-
28-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29-
30-
### `yarn eject`
31-
32-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33-
34-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35-
36-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37-
38-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39-
40-
## Learn More
41-
42-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43-
44-
To learn React, check out the [React documentation](https://reactjs.org/).
45-
46-
### Code Splitting
47-
48-
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49-
50-
### Analyzing the Bundle Size
51-
52-
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53-
54-
### Making a Progressive Web App
55-
56-
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57-
58-
### Advanced Configuration
59-
60-
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61-
62-
### Deployment
63-
64-
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65-
66-
### `yarn build` fails to minify
67-
68-
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
2+
## INTRO
3+
This is todo-list front-end app. <br/>
4+
This app call an RESTful API.<br/>
5+
Framework: ReactJs Class Programming<br/>
6+
Build: npm<br/>
7+
8+
### DEVELOPMENT
9+
1. Set proxy, must to be a string in package.json file
10+
11+
2. For example
12+
"proxy": "https://backend.example.com"
13+
14+
3. Run project
15+
npm install && npm start || yarn install && yarn start
16+
17+
### DEPLOYMENT
18+
Set Proxy to deloy Heroku:
19+
1. When deploy on heroku, just push only package-lock.json or yarn.lock. Dont push both those files!
20+
npm install || yarn install
21+
22+
2. Create static.json file
23+
{
24+
"root": "build/",
25+
"clean_urls": false,
26+
"routes": {
27+
"/**": "index.html"
28+
},
29+
"https_only": true,
30+
"headers": {
31+
"/**": {
32+
"Strict-Transport-Security": "max-age=7776000"
33+
}
34+
},
35+
"proxies": {
36+
"/api/": {
37+
"origin": "${API_URL}"
38+
}
39+
}
40+
}
41+
42+
3. Push file to heroku
43+
git push heroku master
44+
45+
4. Config proxy heroku
46+
All request from react contain "/api/abc" -> "/abc"
47+
For example:
48+
From react: axios.get("/api/search-items") → ${API_URL}/search-items
49+
From react: axios.get("/api/users/me") → ${API_URL}/users/me
50+
(!)Therefore, run this cmd to set proxy var in heroku:
51+
heroku config:set API_URL="https://backend.example.com/api"

package.json

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
11
{
2-
"name": "todolist",
3-
"version": "0.1.0",
4-
"private": true,
5-
"dependencies": {
6-
"@testing-library/jest-dom": "^4.2.4",
7-
"@testing-library/react": "^9.3.2",
8-
"@testing-library/user-event": "^7.1.2",
9-
"react": "^16.13.1",
10-
"react-dom": "^16.13.1",
11-
"react-scripts": "3.4.3"
12-
},
13-
"scripts": {
14-
"start": "react-scripts start",
15-
"build": "react-scripts build",
16-
"test": "react-scripts test",
17-
"eject": "react-scripts eject"
18-
},
19-
"eslintConfig": {
20-
"extends": "react-app"
21-
},
22-
"browserslist": {
23-
"production": [
24-
">0.2%",
25-
"not dead",
26-
"not op_mini all"
27-
],
28-
"development": [
29-
"last 1 chrome version",
30-
"last 1 firefox version",
31-
"last 1 safari version"
32-
]
33-
}
34-
}
2+
"name": "todolist",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@testing-library/jest-dom": "^4.2.4",
7+
"@testing-library/react": "^9.3.2",
8+
"@testing-library/user-event": "^7.1.2",
9+
"react": "^16.13.1",
10+
"react-dom": "^16.13.1",
11+
"react-scripts": "3.4.3"
12+
},
13+
"scripts": {
14+
"start": "react-scripts start",
15+
"build": "react-scripts build",
16+
"test": "react-scripts test",
17+
"eject": "react-scripts eject"
18+
},
19+
"eslintConfig": {
20+
"extends": "react-app"
21+
},
22+
"browserslist": {
23+
"production": [
24+
">0.2%",
25+
"not dead",
26+
"not op_mini all"
27+
],
28+
"development": [
29+
"last 1 chrome version",
30+
"last 1 firefox version",
31+
"last 1 safari version"
32+
]
33+
},
34+
"proxy": "https://vhk-services-api.herokuapp.com/"
35+
}

static.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"root": "build/",
3+
"clean_urls": false,
4+
"routes": {
5+
"/**": "index.html"
6+
},
7+
"https_only": true,
8+
"headers": {
9+
"/**": {
10+
"Strict-Transport-Security": "max-age=7776000"
11+
}
12+
},
13+
"proxies": {
14+
"/api/": {
15+
"origin": "${API_URL}"
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)