Fix the default external app urls

They were hardcoded to localhost:9200 instead of using the server url
config.
This commit is contained in:
Benedikt Kulmann
2020-09-10 09:10:38 +02:00
parent dfbb509b01
commit 280542989b
+14 -2
View File
@@ -72,11 +72,11 @@ func (p Phoenix) getPayload() (payload []byte, err error) {
p.config.Phoenix.Config.ExternalApps = []config.ExternalApp{
{
ID: "accounts",
Path: "https://localhost:9200/accounts.js",
Path: singleJoiningSlash(p.config.Phoenix.Config.Server, "accounts.js"),
},
{
ID: "settings",
Path: "https://localhost:9200/settings.js",
Path: singleJoiningSlash(p.config.Phoenix.Config.Server, "settings.js"),
},
}
}
@@ -109,6 +109,18 @@ func (p Phoenix) getPayload() (payload []byte, err error) {
return
}
func singleJoiningSlash(a, b string) string {
aslash := strings.HasSuffix(a, "/")
bslash := strings.HasPrefix(b, "/")
switch {
case aslash && bslash:
return a + b[1:]
case !aslash && !bslash:
return a + "/" + b
}
return a + b
}
// Config implements the Service interface.
func (p Phoenix) Config(w http.ResponseWriter, r *http.Request) {