app.listen(8080, function () {
console.log("listening on 8080");
});
app.use(express.static(path.join(__dirname, "react/dist/index.html")));
app.get("/", (요청, 응답) => {
응답.sendFile(path.join(__dirname, "react/dist/index.html"));
});
파일경로 설저 맞게 했는데 에러가 나서 (아무것도 안뜨고 흰페이지만 뜨고 콘솔창에
http://localhost:8080/assets/index-DVoHNO1Y.js net::ERR_ABORTED 404 (Not Found)
에러뜸 ) 찾아보니 index.html 파일의 경로를 직접 설정하는 것이 아니라,
정적 파일들을 포함하는 디렉토리를 지정해야 합니다. 하면서
// app.use(express.static(path.join(__dirname, "react", "dist")));
// app.get("/", (req, res) => {
// res.sendFile(path.join(__dirname, "react", "dist", "index.html"));
// }); 이런방식으로 쓰라고해서 해보니 에러가 안나더라고요. 왜그러죠 ?
사용법이 바뀐건가요?
그리고 서버창 하나 띄어놓고 리액트 미리보기 창 해보라고 했는데 어떻게 동시에 서버 띄우죠?터미널에서 하나는 중단시켜야되는데
-
이 게시글은
김수현에 의해 1 년 전에 수정됐습니다.
-
이 게시글은
김수현에 의해 1 년 전에 수정됐습니다.