From 0239c9cf05b789ecec1980c9f01344ad4d2c35df Mon Sep 17 00:00:00 2001 From: bamurtaugh Date: Mon, 19 Apr 2021 12:21:28 -0700 Subject: [PATCH 1/2] Update ports --- .devcontainer/devcontainer.json | 8 ++++---- README.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 08217f5..e5569db 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -21,11 +21,11 @@ // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [3000], - // Use 'portsAttributes' to set default properties for specific forwarded ports. - // You can use a port number (i.e. 3000), range of numbers, or a regex to match the running process. + // Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference. "portsAttributes": { - ".+/server.js": { - "label": "Hello Remote World" + "3000": { + "label": "Hello Remote World", + "onAutoForward": "notify" } }, diff --git a/README.md b/README.md index 3dd7669..4083a81 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Some things to try: **Open browser automatically:** As an example change, let's update the `portsAttributes` in the `.devcontainer/devcontainer.json` file to open a browser when our port is automatically forwarded. - Open the `.devcontainer/devcontainer.json` file. - - Modify your `portsAttributes` to include a new attribute (you can add it underneath the `label` attribute): `"onAutoForward": "openBrowser"`. + - Modify the `"onAutoForward"` attribute in your `portsAttributes` from `"notify"` to `"openBrowser"`. - Press F1 and select the **Remote-Containers: Rebuild Container** or **Codespaces: Rebuild Container** command so the modifications are picked up. ## Contributing From 25bbfcc1e7f95ed112ade2992f1b2136fc9bb64a Mon Sep 17 00:00:00 2001 From: bamurtaugh Date: Mon, 19 Apr 2021 19:29:58 +0000 Subject: [PATCH 2/2] Add readme comment --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4083a81..ef93616 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ Some things to try: - Clicking on `Open in Browser` in the notification telling you: `Your service running on port 3000 is available`. - Clicking the globe icon in the 'Ports' view. The 'Ports' view gives you an organized table of your forwarded ports, and you can access it with the command **Ports: Focus on Ports View**. - Notice port 3000 in the 'Ports' view is labeled "Hello Remote World." In `devcontainer.json`, you can set `"portsAttributes"`, such as a label for your forwarded ports and the action to be taken when the port is autoforwarded. + - If we didn't know the port was 3000, we could've used a regex instead of "3000" in the `"portsAttributes"`, such as ".+/server.js". > **Note:** In Remote - Containers, you can access your app at `http://localhost:3000` in a local browser. But in a browser-based Codespace, you must click the link from the notification or the `Ports` view so that the service handles port forwarding in the browser and generates the correct URL.