1) curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
2) sudo apt-get install nodejs
(프로젝트 디렉토리 위치로 이동해서 설치해야됨 )
const http = require("http");
const express = require("express");
const path = require("path");
const app = express();
const port = 8080;
app.get("/ping", (req, res) => {
res.send("pong");
});
app.use(express.static(path.join(__dirname, "build")));
app.get("/*", (req, res) => {
res.set({
"Cache-Control": "no-cache, no-store, must-revalidate",
Pragma: "no-cache",
Date: Date.now()
});
res.sendFile(path.join(__dirname, "build", "index.html"));
});
http.createServer(app).listen(port, () => {
console.log(`app listening at ${port}`);
});
서버 꺼도 계쏙 접속 가능