Skip to content
Snippets Groups Projects

Add support for https and wss when using domain names

Closed Simon Lefort requested to merge slefort/webapp-lib:cpc/androz2091-wss-support into cpc/cleanup
All threads resolved!
2 files
+ 10
3
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -269,9 +269,16 @@ case class AppPage(appId: AppId, uiId: UIId, instanceId: InstanceId, userId: Use
frag(header(id := "banner"), tag("section")(id := "app"))
Requests.instanceInfo(instanceId).map: appInfo =>
val hostName = dom.window.location.hostname
val protocol = if dom.window.location.protocol.startsWith("https") then "wss" else "ws"
val port = {
val p = dom.window.location.port
if p.length == 0 then (if protocol == "wss" then "443" else "80") else p
}
val endpoint = appInfo.wsEndpoint
.replace("{{hostName}}", hostName)
.replace("{{userId}}", URLEncoder.encode(userId, "UTF-8"))
.replace("{{protocol}}", protocol)
.replace("{{hostName}}", hostName)
.replace("{{port}}", port)
.replace("{{userId}}", URLEncoder.encode(userId, "UTF-8"))
IpBanner(appInfo.shareUrl).renderInto(target.querySelector("#banner"))
app.init(instanceId, userId, endpoint, target.querySelector("#app"))
Loading