showing results for - "next js shared hosting without node js"
Manuel
04 Jun 2017
1const { createServer } = require("http");
2const { parse } = require("url");
3const next = require("next");
4const dev = process.env.NODE_ENV !== "production";
5
6const port = !dev ? process.env.PORT : 3000;
7
8// Create the Express-Next App
9const app = next({ dev });
10const handle = app.getRequestHandler();
11
12app
13  .prepare()
14  .then(() => {
15    createServer((req, res) => {
16      const parsedUrl = parse(req.url, true);
17      const { pathname, query } = parsedUrl;
18      handle(req, res, parsedUrl);
19      console.log("pathname", pathname);
20    }).listen(port, (err) => {
21      if (err) throw err;
22      console.log(`> Ready on http://localhost:${port}`);
23    });
24  })
25  .catch((ex) => {
26    console.error(ex.stack);
27    process.exit(1);
28  });