您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

34 行
949 B

  1. const { createServer } = require("http");
  2. const { parse } = require("url");
  3. const next = require("next");
  4. const cli = require("next/dist/cli/next-start");
  5. const dev = process.env.NODE_ENV !== "production";
  6. const app = next({ dev });
  7. const handle = app.getRequestHandler();
  8. // require("dotenv").config();
  9. const port = process.env.PORT || "14009";
  10. app.prepare().then(() => {
  11. createServer((req, res) => {
  12. const parsedUrl = parse(req.url, true);
  13. const { pathname, query } = parsedUrl;
  14. // if (pathname === "/") {
  15. // app.render(req, res, "/yamaha/home", query);
  16. // }
  17. // else if (pathname === "/yamaha") {
  18. // app.render(req, res, "/yamaha/home", query);
  19. // } else if (pathname === "/suzuki") {
  20. // app.render(req, res, "/suzuki/home", query);
  21. // }
  22. // else {
  23. handle(req, res, parsedUrl);
  24. // }
  25. }).listen(port, (err) => {
  26. if (err) throw err;
  27. console.log(`Ready on port ${port}`);
  28. });
  29. });
  30. // cli.nextStart(["-p", port]);