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:
Open the workspace.json
file in your NextJS project.
Find the serve
target under your app's configuration.
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"
}
}
}
Save the workspace.json
file.
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.