fix(scripts/develop): allow empty access-url for devtunnel (#23166)

This commit is contained in:
Mathias Fredriksson
2026-03-17 20:06:55 +02:00
committed by GitHub
parent cd163d404b
commit c2243addce
2 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -42,6 +42,7 @@ const (
defaultAPIPort = "3000"
defaultWebPort = "8080"
defaultProxyPort = "3010"
defaultAccessURL = "http://127.0.0.1:%d"
defaultPassword = "SomeSecurePassword!"
defaultStarterTemplate = "docker"
healthTimeout = 60 * time.Second
@@ -85,7 +86,8 @@ func main() {
{
Flag: "access-url",
Env: "CODER_DEV_ACCESS_URL",
Description: "Override access URL.",
Default: defaultAccessURL,
Description: "Override access URL. The %d placeholder will be replaced with the API port. Set to empty to enable devtunnel (pit-1.try.coder.app).",
Value: serpent.StringOf(&cfg.accessURL),
},
{
@@ -192,8 +194,8 @@ func (c *devConfig) validate() error {
// resolveEnv sets defaults, unsets leaked credentials, resolves
// filesystem paths, and computes the child process environment.
func (c *devConfig) resolveEnv() error {
if c.accessURL == "" {
c.accessURL = fmt.Sprintf("http://127.0.0.1:%d", c.apiPort)
if strings.Contains(c.accessURL, "%d") {
c.accessURL = fmt.Sprintf(c.accessURL, c.apiPort)
}
// Prevent inherited credentials from leaking into child
+1 -1
View File
@@ -289,7 +289,7 @@ func TestDevConfigResolveEnv(t *testing.T) {
t.Setenv("CODER_SESSION_TOKEN", "leaked")
t.Setenv("CODER_URL", "https://leaked.example.com")
cfg := &devConfig{apiPort: 3000}
cfg := &devConfig{apiPort: 3000, accessURL: defaultAccessURL}
require.NoError(t, cfg.resolveEnv())
wd, _ := os.Getwd()