Skip to content

Instantly share code, notes, and snippets.

@cto-4piens
Created July 8, 2019 13:44
Show Gist options
  • Save cto-4piens/ceaef3a43dbab08a634984612cf6d030 to your computer and use it in GitHub Desktop.
Save cto-4piens/ceaef3a43dbab08a634984612cf6d030 to your computer and use it in GitHub Desktop.
[express로 build완료한 react app 서빙하기] #express #react-app #build
//백엔드와 프론트엔드 폴더가 완전히 분리되어 있는 상태이다.
const express = require('express');
const path = require('path');
const app = express();
const staticPath = path.join(__dirname, '../frontend/build')
console.log(staticPath)
app.use(express.static(staticPath));
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname, '../frontend/build', 'index.html'));
})
app.listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment