Skip to content

Commit 816660c

Browse files
committed
let shared port protocol call shots for now
1 parent 755d1ef commit 816660c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

coderd/workspaceapps/request.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,14 @@ func (r Request) getDatabase(ctx context.Context, db database.Store) (*databaseR
287287
// whether the app is a slug or a port and whether there are multiple agents
288288
// in the workspace or not.
289289
var (
290-
agentNameOrID = r.AgentNameOrID
291-
appURL string
292-
appSharingLevel database.AppSharingLevel
290+
agentNameOrID = r.AgentNameOrID
291+
appURL string
292+
appSharingLevel database.AppSharingLevel
293+
// First check if it's a port-based URL with an optional "s" suffix for HTTPS.
293294
potentialPortStr = strings.TrimSuffix(r.AppSlugOrPort, "s")
294295
portUint, portUintErr = strconv.ParseUint(potentialPortStr, 10, 16)
295296
)
296297
if portUintErr == nil {
297-
// If we fail to parse the port, see if it's a port with a trailing "s" for
298-
// HTTPS.
299298
protocol := "http"
300299
if strings.HasSuffix(r.AppSlugOrPort, "s") {
301300
protocol = "https"
@@ -350,6 +349,10 @@ func (r Request) getDatabase(ctx context.Context, db database.Store) (*databaseR
350349
}
351350
// No port share found, so we keep default to owner.
352351
} else {
352+
if ps.Protocol == database.PortShareProtocolHttps {
353+
// Apply HTTPS protocol if specified.
354+
appURL = fmt.Sprintf("https://127.0.0.1:%d", portUint)
355+
}
353356
appSharingLevel = ps.ShareLevel
354357
}
355358
} else {

0 commit comments

Comments
 (0)