Port Forwarding
You can forward ports in your CDEs to test and debug your application.
Port forwarding gives you access to TCP ports running within your CDE. For example, if you're running a web application on a particular port in your CDE, you can forward that port. This allows you to access the application from the browser on your local machine for testing and debugging.
When an application running inside a Gitspace prints output to the terminal that contains a localhost URL, such as http://localhost:PORT
or http://127.0.0.1:PORT
, the port is automatically forwarded. If you're using CDE in the browser or in Visual Studio Code, the URL string in the terminal is converted into a link that you can click to view the web page on your local machine.
How to use Port Forwarding
- First, you need to have a service you want to forward. If you don't have one yet but do have Node.js installed, you can run this command to start up a server on
port 3000
:
npx serve
-
Then, navigate to the Ports view in the Panel region (Ports: Focus on Ports View), and select Forward a Port.
-
If you are already logged in to your git provider, you'll be auto-forwarded to
port 3000
. -
Hovering over the Forwarded Address, you can use the inline actions copy the address, open it in your browser, or open an in-editor preview.