강의내용 참고해서 게시판을 만들고 있는데요
db연결하고 싶어서 강의 듣다가 강의 내용대로 코드 작성하였습니다.
제일 상위폴더는 front폴더입니다.
build완료됐구요
8080으로 지정한 상태로 접속시 메인화면 잘 나오고 메뉴 누르면 url바뀌면서 잘 나옵니다 (react-router-dom 사용)
하지만 강의에서처럼, 8080/board처럼 get요청을 하면 index.html파일을 찾지 못하는 오류가 나옵니다.ㅠㅠ
개발자도구에서 네트워크 부분 Name : board , Status : 404
근데 오류메시지에 나온 경로 그대로 복사해서 열어보면 파일은 열립니다..
const express = require("express")
const path = require("path")
const app = express()
const http = require("http").createServer(app)
http.listen(8080, function () {
console.log("listening on 8080")
})
app.use(express.static(path.join(__dirname, "../front/build")))
app.get("/", function (요청, 응답) {
응답.sendFile(path.join(__dirname, "build/index.html "))
})
app.get("*", function (요청, 응답) {
응답.sendFile(path.join(__dirname, "build/index.html "))
})