You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

56 lines
1.5 KiB

  1. const { createServer } = require("http");
  2. const express = require('express')
  3. const { parse } = require("url");
  4. const next = require("next");
  5. const { createProxyMiddleware } = require('http-proxy-middleware');
  6. const cli = require("next/dist/cli/next-start");
  7. const dev = process.env.NODE_ENV !== "production";
  8. const app = next({ dev });
  9. const handle = app.getRequestHandler();
  10. // require("dotenv").config();
  11. console.log(process.env.PORT);
  12. const port = process.env.PORT || "14011";
  13. app.prepare().then(() => {
  14. // const server = createServer((req, res) => {
  15. // const parsedUrl = parse(req.url, true);
  16. // const { pathname,query } = parsedUrl;
  17. // if(pathname=='/index.html.var'){
  18. // app.render(req, res, "/home", query);
  19. // }
  20. // // if (pathname === "/") {
  21. // // console.log("=>",parsedUrl);
  22. // // }
  23. // // if(!pathname.includes('api/util')){
  24. // // if(pathname.includes('/product')){
  25. // // var company = pathname.substring(1,pathname.lastIndexOf('/product'));
  26. // // if(company.length>1)parsedUrl.query = {'company':company,...parsedUrl.query};
  27. // // }
  28. // // console.log("rendering..",pathname);
  29. // // }
  30. // else handle(req, res, parsedUrl);
  31. // });
  32. const server = express();
  33. server.use(
  34. '/uploads',
  35. createProxyMiddleware({
  36. target: process.env.BACKEND_SERVER_URI,
  37. changeOrigin: true,
  38. }),
  39. );
  40. server.all('*', (req, res) => handle(req, res));
  41. server.listen(port, (err) => {
  42. if (err) throw err;
  43. console.log(`Ready on port ${port}`);
  44. });
  45. });