Forwarding ports in your codespace

アプリケーションのテストとデバッグのために、codespace中のポートをフォワードできます。

Codespaces is available for organizations using GitHub Team or GitHub Enterprise Cloud. 詳しい情報については「GitHubの製品」を参照してください。

About forwarded ports

ポート転送を使用すると、Codespaces 内で実行されている TCP ポートにアクセスできます。 For example, if you're running a web application on port 4000, you can access the application from your browser to test and debug the application.

When an application running inside a codespace outputs a port to the console, Codespaces detects the localhost URL pattern and automatically forwards the port. You can click on the URL in the terminal to open the port in a browser. たとえば、アプリケーションが http://127.0.0.1:4000 または http://localhost:4000 をコンソールに出力する場合、ログは出力をポート 4000 のクリック可能な URL に自動的に変換します。

Automatic port forwarding

ポートの手動転送、転送されたポートへのラベル付け、転送されたポートのパブリックへの共有、転送されたポートの codespace 設定への追加ができます。

Forwarding a port

You can manually forward a port that wasn't forwarded automatically.

  1. codespaceで、テキストエディタの下で"Ports(ポート)"をクリックしてください。 ポートタブ
  2. Under the list of ports, click Add port. Add port button
  3. Type the port number or address, then press enter. Text box to type port button

Labeling a port

You can label a port to make the port more easily identifiable in a list.

  1. codespaceで、テキストエディタの下で"Ports(ポート)"をクリックしてください。 ポートタブ
  2. Hover over the port you want to label, then click the label icon. Label icon for port
  3. ポートのラベルを入力し、Enterを押してください。 ポートのラベルを入力するためのテキストボックス

Sharing a port

If you want to share a forwarded port with others, you need to make the port public. After you make a port public, anyone with the port's URL can view the running application without needing to authenticate.

  1. codespaceで、テキストエディタの下で"Ports(ポート)"をクリックしてください。 ポートタブ
  2. Right click the port you want to share, then click Make Public. Option to make port public in right-click menu
  3. To the right of the local address for the port, click the copy icon. Copy icon for port URL
  4. Send the copied URL to the person you want to share the port with.

Adding a port to the codespace configuration

You can add a forwarded port to the Codespaces configuration for the repository, so the port will automatically be forwarded for all codespaces created from the repository. After you update the configuration, any previously created codespaces must be rebuilt for the change to apply. 詳しい情報については、「プロジェクトの Codespaces を設定する」を参照してください。

forwardPorts プロパティで .devcontainer.json ファイルで転送ポートを手動で設定するか、codespace の [Ports] パネルを使用できます。

  1. codespaceで、テキストエディタの下で"Ports(ポート)"をクリックしてください。 ポートタブ
  2. Right click the port you want to add to the codespace configuration, then click Set Label and Update devcontainer.json. Option to set label and add port to devcontainer.json in the right-click menu
  3. ポートのラベルを入力し、Enterを押してください。 ポートのラベルを入力するためのテキストボックス

このドキュメントは役立ちましたか?

プライバシーポリシー

これらのドキュメントを素晴らしいものにするのを手伝ってください!

GitHubのすべてのドキュメントはオープンソースです。間違っていたり、はっきりしないところがありましたか?Pull Requestをお送りください。

コントリビューションを行う

OR, コントリビューションの方法を学んでください。

問題がまだ解決していませんか?