Business Port Preview
About 249 wordsLess than 1 minute
Business Port Preview explains how to reach the ports your services listen on inside a Workspace.
When to use: when you started a web service in the environment and want to open it in a browser.
Services running in the environment can be previewed through WebIDE or the VS Code/Cursor client.
Method 1: WebIDE Port Mapping
Add port mappings in the PORTS panel of the WebIDE console, and the system generates the URL automatically.
The business port URL can be obtained in two ways:
- From the PORTS panel in the WebIDE console
- From the environment variable
CNB_VSCODE_PROXY_URI. For example:https://xxxxxxxxxx-{{port}}.cnb.build, replace{{port}}with the actual port number.
Tips
Note: The service must be started on 0.0.0.0 to be accessible via this method. Services started on localhost or 127.0.0.1 cannot use this method.
Using a business service listening on port 3000 as an example:
# 1. Start the service; it must listen on 0.0.0.0 rather than 127.0.0.1
node app.js
# 2. {{port}} in CNB_VSCODE_PROXY_URI is a port placeholder.
# Replace it with the actual port (3000); the resulting URL opens in the browser
echo "$CNB_VSCODE_PROXY_URI" | sed "s/{{port}}/3000/"Method 2: VS Code/Cursor Port Forwarding
Use the Port Forward feature of the VS Code/Cursor client to forward business ports to your local machine.