SPA 페이지로 구현했더니 새로고침을 하거나 뒤로가기, URL 입력 시에 Not Found 에러가 발생하였다.
// app.js
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "../client/build", "index.html"));
});
모든 라우팅 코드 뒤에 *로 모든 경로를 처리해준다.
간단한데 왜 삽질을 했냐면
app.use(express.static(path.join(__dirname, "../client/build")));
이 static 코드가 production 모드에서만 실행이 되도록 설정되어 있었기 때문에 파일이 나타나지 않던 문제였다.