question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Next.js v12.0.8 - Nx executor seem to run Next in a custom server

See original GitHub issue

Current Behavior

Seems like Next.js identifies the server nx’s executor is using as a custom server.

More details on my original ticket in next’s repo - https://github.com/vercel/next.js/issues/33450

Expected Behavior

Should use Next’s server as is.

Steps to Reproduce

This issue may not be prioritized if details are not provided to help us reproduce the issue.

Failure Logs

 Error: To use middleware you must provide a `hostname` and `port` to the Next.js Server

Environment

  Node : 16.13.0
  OS   : darwin x64
  yarn : 3.1.0
  
  nx : 13.4.6
  @nrwl/angular : undefined
  @nrwl/cli : 13.4.6
  @nrwl/cypress : 13.4.6
  @nrwl/devkit : 13.4.6
  @nrwl/eslint-plugin-nx : 13.4.6
  @nrwl/express : undefined
  @nrwl/jest : 13.4.6
  @nrwl/linter : 13.4.6
  @nrwl/nest : undefined
  @nrwl/next : 13.4.5
  @nrwl/node : 13.4.6
  @nrwl/nx-cloud : undefined
  @nrwl/react : 13.4.6
  @nrwl/react-native : undefined
  @nrwl/schematics : undefined
  @nrwl/tao : 13.4.6
  @nrwl/web : 13.4.6
  @nrwl/workspace : 13.4.6
  @nrwl/storybook : 13.4.6
  @nrwl/gatsby : undefined
  typescript : 4.5.4
  rxjs : 6.6.7
  ---------------------------------------
  Community plugins:
         nx-stylelint: 13.1.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:11
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
jfabraxascommented, Feb 1, 2022

I had the same issue. As a workaround you can add the port and hostname to workspace.json, worked for me

{
   "app": {
      "serve": {
         "builder": "@nrwl/next:server",
         "options": {
            "port": 4200,
            "hostname": "localhost"
         }
      }
   }
}
2reactions
babiecommented, Jan 30, 2022

FYI:

DOS Vulnerability for self-hosted next.js apps using i18n https://github.com/vercel/next.js/security/advisories/GHSA-wr66-vrwm-5g5x

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Features: Custom Server - Next.js
A custom Next.js server allows you to start a server 100% programmatically in order to use custom server patterns. Most of the time,...
Read more >
@nrwl/next:custom-server | Nx
Add a custom server to existing Next.js application. ... By default, Nx will search for custom-server in the default collection provisioned in ...
Read more >
Env vars are undefined in Nextjs v12.0.8 - Stack Overflow
TEST (test env var) but I'm getting undefined . It seems process.env is always empty. I restarted the server but I still don't...
Read more >
Hot Reload MDX changes in Next.js and Nx
A custom server is basically a function with a certain signature that we register on our Nx Next.js executor. The file itself can...
Read more >
Nx Office Hours: Building your website with Next.js - YouTube
Brandon Roberts is joined by fellow Nrwlian Juri Strumpflohner to discuss his ongoing blog series on building websites with Next. js, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found