Skip to content

Commit

Permalink
chore: react-dotenv 설정 및 api_key 환경변수에 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
UnhappyDogChew committed Aug 26, 2023
1 parent 3818c2a commit ed0b114
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ yarn-debug.log*
yarn-error.log*

# api
api_key.json
api_key.json
.env
267 changes: 267 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
"json-server": "^0.17.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-dotenv": "^0.1.3",
"react-router-dom": "^6.15.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"start": "react-dotenv && react-scripts start",
"build": "react-dotenv && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"serve-json": "json-server --watch db.json --port 5000"
Expand All @@ -38,5 +39,11 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"react-dotenv": {
"whitelist": [
"API_URL",
"API_TOKEN"
]
}
}
4 changes: 4 additions & 0 deletions public/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
window.env = {
"API_URL": "https://api.themoviedb.org/3",
"API_TOKEN": "eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI0Njc2YTI0YzVkNGUwZDJjMGFjZjEzYjVhMWQ0NGM1YyIsInN1YiI6IjY0ZTg5MGYzOTBlYTRiMDBjNzM5NmU2YSIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.Rl0CcJmSVYBYQULNSl606D5yM2Mlcz546lpleVVHlhY"
};
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<script id="react-dotenv" src="./env.js"></script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down

0 comments on commit ed0b114

Please sign in to comment.