Skip to content

Commit 8d8950d

Browse files
committed
Create server.js
1 parent 2e2f27c commit 8d8950d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

server.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const http = require("http");
2+
const express = require("express");
3+
const path = require("path");
4+
5+
const app = express();
6+
7+
const port = 27017; //인스턴스 생성시 만들었던 포트번호 기입
8+
9+
app.get("/ping", (req, res) => {
10+
res.send("pong");
11+
});
12+
13+
app.use(express.static(path.join(__dirname, "build")));
14+
15+
app.get("/*", (req, res) => {
16+
res.set({
17+
"Cache-Control": "no-cache, no-store, must-revalidate",
18+
Pragma: "no-cache",
19+
Date: Date.now(),
20+
});
21+
res.sendFile(path.join(__dirname, "build", "index.html"));
22+
});
23+
24+
http.createServer(app).listen(port, () => {
25+
console.log(`app listening at ${port}`);
26+
});

0 commit comments

Comments
 (0)