Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To host a NextJS app using nrwl/next on 0.0.0.0:3000 instead of localhost:3000, you can follow these steps:

  1. Open the workspace.json file in your NextJS project.

  2. Find the serve target under your app's configuration.

  3. Add the --host flag followed by 0.0.0.0 to the command property.

    For example, your serve target might look like this:

    "serve": {
     "executor": "@nrwl/web:dev-server",
     "options": {
       "buildTarget": "my-app:build",
       "port": 3000,
       "command": "node_modules/.bin/next start --host 0.0.0.0"
     },
     "configurations": {
       "production": {
         "buildTarget": "my-app:build:production"
       }
     }
    }
    
  4. Save the workspace.json file.

  5. Run your app using the --configuration flag and specifying the desired configuration (e.g. development, production, etc.).

    For example:

    nx serve my-app --configuration=development
    

    Your app should now be running on 0.0.0.0:3000, accessible from any device on the network.