node.js/Express.js
express + react 연결
DingCoDing
2022. 7. 25. 21:23
반응형
react build한 후 html 파일을
res.sendFile 해주면 된다
const express = require('express')
const app = express()
const path = require('path')
app.listen(8030, function () {
console.log('listening on 8030')
})
app.use(express.static(path.join(__dirname, 'prac/build')));
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, 'prac/build/index.html'));
})반응형