0
나는 익스프레스 서버에서 시작하는 React 앱을 가지고있다. 나는/public /index.html 파일과 그 파일의 복사본을 '/'디렉토리에 넣어 공개 지침서를 가지고있다.잘못된 방향으로 열리는 서버
코드 :
const express = require('express')
const path = require('path')
const port = process.env.PORT || 8080
const app = express()
app.use(express.static(__dirname))
app.get('*', (req,res) => {
res.sendFile(path.resolve(__dirname, './public/index.html'))
})
app.listen(port)
console.log('Server started: '+ port)
내 server.js 파일은 '/'디렉토리에 있습니다.
Express는 index.html을 '/'디렉토리 대신 공개 디렉토리에서 열지 만, 이유는 무엇입니까?