devcontainers / devcontainers/spec
Allow specifying subdirectory to open when port forwarding detected
- Dominant language
- No language data
- Stars
- 5.7k
- Forks
- 496
- PR merge metrics
- No merged PRs in 30d
Description
We would like a way to configure a path (subdirectory) of a site to open from a devcontainer. In VSCode, for example, clicking the `browse` button - or from the automatic prompt to open a browser when a port is forwarded - we could open a site like `http://127.0.0.1:4000/azure-sdk` instead of only `http://127.0.0.1:4000`. For GitHub Codespaces, this would be forwarded port to a remote continer.
To `portAttributes` or `otherPortAttributes`, this would add:
| Property | Type | Description |
| --- | --- | --- |
`path` | string | Optional path relative to the site root to open in a browser e.g., "/blog" on forwarded port 4000 would open `http://127.0.0.1:4000/blog` on localhost.
To the schema for both `portAttributes` or `otherPortAttributes`1, this would look like:
```diff
"portsAttributes": {
"type": "object",
"patternProperties": {
"(^\\d+(-\\d+)?$)|(.+)": {
"type": "object",
"description": "A port, range of ports (ex. \"40000-55000\"), or regular expression (ex. \".+\\\\/server.js\"). For a port number or range, the attributes will apply to that port number or range of port numbers. Attributes which use a regular expression will apply to ports whose associated process command line matches the expression.",
"properties": {
+ "path": {
+ "type": "string",
+ "description": "Optional path relative to the site root to open in a browser e.g., '/blog' on forwarded port 4000 would open `http://127.0.0.1:4000/blog` on localhost."
+ },
"onAutoForward": {
```
See microsoft/vscode-remote-release#9518 for additional context.
1 Since `portAttributes` and `otherPortAttributes` appear to be the same schema, wouldn't a `$ref` to a single object definition be sufficient and easier to maintain?
Contributor guide
Assessment
This issue has not been assessed yet.