1

works without problems: router on pages (/pages) config on: Passenger, Node Js 18, Nextjs 13.2.3, React 17.0.2, React-dom 17.0.2.

Problem: App Router (/src/app) config on Passenger, Nodejs 18, Nextjs 13.4.4, React 18.2.0, React-dom 18.2.0 ....and enter image description here

It seems in my opinion that the problem is: running the nextjs application from the /src/page ... folder and the page.js file, I think so becauce: process.env.PORT is undefined

const { createServer } = require("http");
var https = require('https');

const { parse } = require("url");
const next = require("next");
const dev = process.env.NODE_ENV !== "production";

const fs = require("fs");


const port = !dev ? **process.env.PORT** : 8000;

// Create the Express-Next App
const app = next({ dev });
const handle = app.getRequestHandler();


app
  .prepare()
  .then(() => {
    createServer((req, res) => {
      const parsedUrl = parse(req.url, true);
      const { pathname, query } = parsedUrl;
      handle(req, res, parsedUrl);
      console.log("App.js> pathname", pathname);
    }).listen(port, (err) => {
      if (err) throw err;

      console.log("process.env.PORT:"+process.env.PORT);
      console.log(`APP.js> Ready on http://localhost:${port}`);

    });
  })
  .catch((ex) => {
    console.error(ex.stack);
    process.exit(1);
  });

Your suggestions may help to solve it. Thanks.

Geery.S
  • 121
  • 2
  • 10

0 Answers0