Ask Your Question
1

What is the process for hosting a NextJS app using nrwl/next on 0.0.0.0:3000 instead of localhost:3000?

asked 2022-04-07 11:00:00 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-12-14 17:00:00 +0000

plato gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-04-07 11:00:00 +0000

Seen: 9 times

Last updated: Dec 14 '22