#Next + Express routing issue (Headers sent | Write after end)

3 messages · Page 1 of 1 (latest)

slow crystal
#

Hello,

I'm using Next with a custom express server and I'm getting this error, but can't figure out which file or route that is throwing it.

Error:
https://pastebin.com/EGGxTXEC

I understand that it pertains to sending multiple responses to a single request, but I can't for the life of me figure out where in my code this is happening, as none of the logs seem to point to the actual source of the problem. Any suggestions?

Thanks!

#

Excerpt from my server:

const nextApp = next({ dev: development, hostname: "localhost", port: port });
const handle = nextApp.getRequestHandler();
const expressApp = express();
expressApp.use(express.json());
expressApp.use(express.urlencoded({ extended: true }));

async function StartExpress() {
  await nextApp.prepare();
  const server = https.createServer(httpsOptions, expressApp);
  expressApp.use(handle);

  server.listen(port, (err) => {
    if (err) throw err;
    console.log("Running on port " + server.address().port);
  });
}

StartExpress();
slow crystal
#

The error also doesn't happen consistently, it suddenly appears on some refreshes