app.js 713 Bytes
Newer Older
Yoon, Daeki's avatar
Yoon, Daeki committed
1
2
3
4
import express from "express";
import path from "path";
import cookieParser from "cookie-parser";
import mainRouter from "./routes/index.js";
Kim, Subin's avatar
Kim, Subin committed
5

Yoon, Daeki's avatar
Yoon, Daeki committed
6
7
8
9
10
11
12
// 배포용?
const isProduction = process.env.NODE_ENV === "production";
let root_url = "/";
if (isProduction) {
  root_url = "/app/todayku";
}
const CURRENT_WORKING_DIR = process.cwd();
Kim, Subin's avatar
Kim, Subin committed
13

Yoon, Daeki's avatar
Yoon, Daeki committed
14
const app = express();
Kim, Subin's avatar
Kim, Subin committed
15

Daeki Yoon's avatar
Daeki Yoon committed
16
console.log('current dir', path.join(CURRENT_WORKING_DIR, "client", "build"))
Yoon, Daeki's avatar
Yoon, Daeki committed
17
18
19
20
21
22
23
24
25
26
27
app.use(
  path.join(root_url, "/"),
  express.static(path.join(CURRENT_WORKING_DIR, "client", "build"))
);

app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(path.join(root_url, "/api"), mainRouter);

export default app;