전체적인 참조는 https://leonkong.cc/posts/express-with-react.html 글을 참고했습니다. 이후 생기는 오류를 해결하기 위해 제가했던 방법들에 대한 포스팅 입니다.
전체 디렉토리 구조는 아래와 같습니다.
client
ㄴpublic
ㄴsrc
ㄴpackage.json
server
ㄴserver.js
package.json
"scripts": {
"heroku-postbuild": "cd client && npm install && npm run build",
...
},
app.listen(process.env.PORT || 5000, function () {
...
});
if (process.env.NODE_ENV === "production") {
app.use(express.static("client/build"));
}
app.get("/", (request, response) => {
response.sendFile(path.join(__dirname, "client/build", "index.html"));
});
😊