-
-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (27 loc) · 739 Bytes
/
server.js
File metadata and controls
33 lines (27 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import express from "express"
import next from "next"
import config from "./next.config.mjs"
const dev = process.env.NODE_ENV !== "production"
const app = next({ dev })
const handle = app.getRequestHandler()
const prefix = config.assetPrefix
app
.prepare()
.then(() => {
const server = express()
const router = express.Router()
// use next routes
server.use(`${prefix}`, router)
server.use(`${prefix}/static`, express.static("static"))
server.use(handle)
router.get("*", (req, res) => {
return handle(req, res)
})
server.listen(3001, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:3001${prefix}`)
})
})
.catch((e) => {
console.log(e)
})