@@ -291,7 +291,18 @@ func (r Request) getDatabase(ctx context.Context, db database.Store) (*databaseR
291
291
appURL string
292
292
appSharingLevel database.AppSharingLevel
293
293
portUint , portUintErr = strconv .ParseUint (r .AppSlugOrPort , 10 , 16 )
294
+ protocol = "http"
294
295
)
296
+ // If we fail to parse the port, see if it's a port with a trailing "s" for
297
+ // HTTPS.
298
+ if portUintErr != nil && strings .HasSuffix (r .AppSlugOrPort , "s" ) {
299
+ appSlugOrPort := strings .TrimRight (r .AppSlugOrPort , "s" )
300
+ portUint , portUintErr = strconv .ParseUint (appSlugOrPort , 10 , 16 )
301
+ if portUintErr == nil {
302
+ protocol = "https"
303
+ }
304
+ }
305
+
295
306
if portUintErr == nil {
296
307
if r .AccessMethod != AccessMethodSubdomain {
297
308
// TODO(@deansheather): this should return a 400 instead of a 500.
@@ -312,7 +323,7 @@ func (r Request) getDatabase(ctx context.Context, db database.Store) (*databaseR
312
323
// "anonymous app". We only support HTTP for port-based URLs.
313
324
//
314
325
// This is only supported for subdomain-based applications.
315
- appURL = fmt .Sprintf ("http ://127.0.0.1:%d" , portUint )
326
+ appURL = fmt .Sprintf ("%s ://127.0.0.1:%d" , protocol , portUint )
316
327
appSharingLevel = database .AppSharingLevelOwner
317
328
318
329
// Port sharing authorization
0 commit comments