Run BFF Locally
To run both the app and BFF locally, ports must be configured correctly since both default to using ports 3000 and 4200. Follow the steps below to modify the BFF ports.
Steps
-
Locate the BFF Entry in the
.env
File
Find the relevant BFF entry in the.env
file for the desired market. Example:NEXT_PUBLIC_MY_BFF_API_URL
inapps/example.com/us/.env
. -
Update the URL Port
Modify the URL to use an unused port, e.g.,http://localhost:4201
. -
Open
project.json
in the BFF Project Root
Navigate to the root of the BFF project and openproject.json
. -
Modify the
serve
andserve-base
Options- The
serve-base
option serves the Next.js app by default. - The
serve
option performs the same function with SSL enabled.
- The
-
Update the
serve
Configuration
Add the following properties insideserve
:"serve": { "options": { "serveTarget": "my-bff-us-web:serve-base", "targetPort": 4201, "port": 3001 } }
-
Update the
serve-base
Configuration
Add the following properties insideserve-base
:"serve-base": { "options": { "buildTarget": "my-bff-us-web:build", "dev": true, "port": 4201 } }
-
Run the BFF Locally
Execute the following command to start the BFF:nx run my-bff-us-web:serve