Skip to content

Commit e1d9017

Browse files
feat: support --trusted-origins
1 parent 312b35d commit e1d9017

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

src/code-server/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ VS Code in the browser
3434
| port | The port to bind to for the code-server. | string | 8080 |
3535
| socket | Path to a socket. When specified, host and port will be ignored. | string | - |
3636
| socketMode | File mode of the socket when using the socket option. | string | - |
37+
| trustedOrigins | Comma-separated list of trusted-origins to disable origin check for. Useful if not able to access reverse proxy configuration. | string | - |
3738
| verbose | Enable verbose logging. | boolean | false |
3839
| version | The version of code-server to install. If empty, installs the latest version. | string | - |
3940
| welcomeText | Text to show on login page. | string | - |

src/code-server/devcontainer-feature.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@
100100
"default": "",
101101
"description": "File mode of the socket when using the socket option."
102102
},
103+
"trustedOrigins": {
104+
"type": "string",
105+
"default": "",
106+
"description": "Comma-separated list of trusted-origins to disable origin check for. Useful if not able to access reverse proxy configuration."
107+
},
103108
"verbose": {
104109
"type": "boolean",
105110
"default": false,

src/code-server/install.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ if [[ "$VERBOSE" == "true" ]]; then
9191
FLAGS+=(--verbose)
9292
fi
9393

94+
IFS=',' read -ra trusted_origins <<<"$TRUSTEDORIGINS"
95+
declare -p trusted_origins
96+
97+
for trusted_origin in "${trusted_origins[@]}"; do
98+
FLAGS+=(--trusted-origins "$trusted_origin")
99+
done
100+
94101
cat > /usr/local/bin/code-server-entrypoint <<EOF
95102
#!/usr/bin/env bash
96103
set -e
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library bundled with the devcontainer CLI
5+
source dev-container-features-test-lib
6+
7+
# Feature-specific tests
8+
check "code-server version" code-server --version
9+
check "code-server running" pgrep -f 'code-server/lib/node.*/code-server'
10+
check "code-server listening" lsof -i "@127.0.0.1:8080"
11+
12+
check "code-server trusted-origins" grep '"--trusted-origins".*"dev.coder.com".*"--trusted-origins".*"coder.com"' < /usr/local/bin/code-server-entrypoint
13+
14+
# Report results
15+
reportResults

test/code-server/scenarios.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,13 @@
200200
"verbose": true
201201
}
202202
}
203+
},
204+
"code-server-trusted-origins": {
205+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
206+
"features": {
207+
"code-server": {
208+
"trustedOrigins": ["dev.coder.com", "coder.com"]
209+
}
210+
}
203211
}
204212
}

0 commit comments

Comments
 (0)