Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Mar 23, 2024
1 parent 369acf8 commit b74e7e5
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions envs/local.go
Expand Up @@ -259,15 +259,11 @@ func (l *Local) webServer() Envs {
host := fmt.Sprintf("127.0.0.1:%s", port)

if proxyConf, err := proxy.Load(util.GetHomeDir()); err == nil {
for _, domain := range proxyConf.GetDomains(l.Dir) {
// we get the first one only
host = domain
if pidFile.Scheme == "http" {
port = "80"
} else {
port = "443"
}
break
host = proxyConf.GetDomains(l.Dir)[0]

This comment has been minimized.

Copy link
@tucksaun

tucksaun Mar 23, 2024

Contributor

have you tried with a projet that didn't configure any custom domain? I'm afraid it will cause an "index out of range" error

This comment has been minimized.

Copy link
@phsm

phsm Mar 23, 2024

I confirm.
Just started following Symfony tutorial, got this:

2024/03/23 14:09:56 http: panic serving [::1]:64620: runtime error: index out of range [0] with length 0
goroutine 81 [running]:
net/http.(*conn).serve.func1()
	net/http/server.go:1898 +0xb0
panic({0x1033b6e00?, 0x140004700d8?})
	runtime/panic.go:770 +0x124
github.com/symfony-cli/symfony-cli/envs.(*Local).webServer(0x1400019a300)
	github.com/symfony-cli/symfony-cli/envs/local.go:262 +0x508
github.com/symfony-cli/symfony-cli/envs.(*Local).Extra(0x1400019a300)
	github.com/symfony-cli/symfony-cli/envs/local.go:210 +0x300
github.com/symfony-cli/symfony-cli/envs.AsMap({0x10340a560, 0x1400019a300})
	github.com/symfony-cli/symfony-cli/envs/envs.go:86 +0x210
github.com/symfony-cli/symfony-cli/local/php.(*Server).generateEnv(0x1400022b340, 0x140001ac000)
	github.com/symfony-cli/symfony-cli/local/php/envs.go:76 +0x7fc
github.com/symfony-cli/symfony-cli/local/php.(*Server).Serve(0x1400022b340, {0x1034075f8, 0x140001ba000}, 0x140001ac000, 0x1400019a2a0)
	github.com/symfony-cli/symfony-cli/local/php/php_server.go:209 +0x58
github.com/symfony-cli/symfony-cli/local/http.(*Server).Handler(0x140003c3a00, {0x1034075f8, 0x140001ba000}, 0x140001ac000)
	github.com/symfony-cli/symfony-cli/local/http/http.go:244 +0x44c
github.com/symfony-cli/symfony-cli/local/http.(*Server).ProxyHandler(0x140003c3a00, {0x1034071a8, 0x140001b6000}, 0x140001ac000)
	github.com/symfony-cli/symfony-cli/local/http/http.go:187 +0x240
net/http.HandlerFunc.ServeHTTP(0x0?, {0x1034071a8?, 0x140001b6000?}, 0x14000447b50?)
	net/http/server.go:2166 +0x38
net/http.serverHandler.ServeHTTP({0x1400019a0c0?}, {0x1034071a8?, 0x140001b6000?}, 0x6?)
	net/http/server.go:3137 +0xbc
net/http.(*conn).serve(0x1400019c000, {0x103408450, 0x1400046c120})
	net/http/server.go:2039 +0x508
created by net/http.(*Server).Serve in goroutine 68
	net/http/server.go:3285 +0x3f0
^C

It seems the function is looking for ~/proxy.json. I don't have this file, obviously.

if pidFile.Scheme == "http" {
port = "80"
} else {
port = "443"
}
}

Expand Down

0 comments on commit b74e7e5

Please sign in to comment.