File tree Expand file tree Collapse file tree 5 files changed +39
-11
lines changed
Expand file tree Collapse file tree 5 files changed +39
-11
lines changed Original file line number Diff line number Diff line change 1- const { REACT_APP_HOST_ADDRESS , REACT_APP_SERVER_PORT } = process . env ;
1+ const {
2+ REACT_APP_NODE_ENV , //
3+ REACT_APP_SERVER_HOST_ADDRESS , //
4+ REACT_APP_SERVER_PORT , //
5+ } = process . env ;
26
37export class HTTP {
48 private domain : string = "" ;
@@ -43,7 +47,11 @@ export class HTTP {
4347}
4448
4549const instance = new HTTP (
46- `http://${ REACT_APP_HOST_ADDRESS } :${ REACT_APP_SERVER_PORT } `
50+ `http://${
51+ REACT_APP_NODE_ENV === "production"
52+ ? REACT_APP_SERVER_HOST_ADDRESS
53+ : "localhost"
54+ } :${ REACT_APP_SERVER_PORT } `
4755) ;
4856
4957export default instance ;
Original file line number Diff line number Diff line change 1+ # If you want to deploy the production, put the "production".
2+ REACT_APP_NODE_ENV = " development"
3+
14# Client port number to open this react-app.
2- PORT = 80
5+ PORT = 3000
36
47# Enter the same value as the PORT environment variable written in .server.env.
58REACT_APP_SERVER_PORT = 8000
69
710# Put the IP or host address of the computer you are using.
8- REACT_APP_HOST_ADDRESS = " 52.78.64.144"
11+ # The REACT_APP_SERVER_HOST_ADDRESS below only works when REACT_APP_NODE_ENV is "production", otherwise it works as "localhost".
12+ REACT_APP_SERVER_HOST_ADDRESS = " localhost"
Original file line number Diff line number Diff line change 1+ # If you want to deploy the production, put the "production".
2+ NODE_ENV = " development"
3+
14# NodeJS
25PORT = 8000
3- HOST_ADDRESS = " 52.78.64.144" # Put the IP or host address of the computer you are using.
46
5- # for accessing from Nodejs to MySQL
7+ # Put the IP or host address of the computer you are using.
8+ # The HOST_ADDRESS below only works when NODE_ENV is "production", otherwise it works as "localhost".
9+ HOST_ADDRESS = " localhost"
10+
11+ # For accessing from Nodejs to MySQL
612DB_HOST = " db"
713DB_USER = " root"
814DB_PSWORD = " password"
Original file line number Diff line number Diff line change 1+ # Print message on console.
2+ echo " [info] Starting server and client..."
3+
4+ # OS variable
15CHECK_OS=" ` uname -s` "
26
7+ # Check OS and then RUN the services
38if [[ ${CHECK_OS} = " Darwin" * ]]; then
49 npm run build --prefix ./server/app && docker-compose -f ./server/docker-compose.yml --env-file ./config/.server.env up -d && npm run start:client
510elif [[ " $CHECK_OS " = " Linux" * ]]; then
@@ -11,3 +16,6 @@ elif [[ ${CHECK_OS} = "MINGW64"* ]]; then
1116elif [[ ${CHECK_OS} = " CYGWIN" * ]]; then
1217 npm run start:windows
1318fi
19+
20+ # Print message on console.
21+ echo " [info] Now enjoy the your dev-portfolio web!!"
Original file line number Diff line number Diff line change @@ -9,13 +9,15 @@ dotenv.config({ path: '../../config/.server.env' });
99
1010const app = express ( ) ;
1111const PORT = process . env . PORT || 8000 ;
12- const HOST_ADDRESS = process . env . HOST_ADDRESS || 'localhost'
12+ const HOST_ADDRESS =
13+ process . env . NODE_ENV === 'production'
14+ ? process . env . HOST_ADDRESS || 'localhost'
15+ : 'localhost' ;
1316
1417const swaggerSpec = YAML . load ( path . join ( __dirname , './swagger.yaml' ) ) ;
15- const portInjectedSwaggerSpec = JSON . stringify ( swaggerSpec ) . replace (
16- '{PORT}' ,
17- PORT . toString ( )
18- ) . replace ( '{HOST_ADDRESS}' , HOST_ADDRESS ) ;
18+ const portInjectedSwaggerSpec = JSON . stringify ( swaggerSpec )
19+ . replace ( '{PORT}' , PORT . toString ( ) )
20+ . replace ( '{HOST_ADDRESS}' , HOST_ADDRESS ) ;
1921
2022import visitor from './src/apis/visitor' ;
2123
You can’t perform that action at this time.
0 commit comments