diff --git a/keyserver/.well-known/apple-app-site-association b/keyserver/.well-known/apple-app-site-association --- a/keyserver/.well-known/apple-app-site-association +++ b/keyserver/.well-known/apple-app-site-association @@ -9,13 +9,13 @@ "appIDs": [ "H98Y8MH53M.app.comm" ], "components": [ { - "/": "*" + "/": "/invite/*" } ] }, { "appID": "H98Y8MH53M.app.comm", - "paths": [ "*" ] + "paths": [ "/invite/*" ] } ] } diff --git a/keyserver/src/keyserver.js b/keyserver/src/keyserver.js --- a/keyserver/src/keyserver.js +++ b/keyserver/src/keyserver.js @@ -109,6 +109,8 @@ downloadHandler(uploadDownloadResponder), ); + router.get('/invite/:secret', inviteResponder); + // $FlowFixMe express-ws has side effects that can't be typed router.ws('/ws', onConnection); router.get('/worker/:worker', webWorkerResponder); @@ -127,15 +129,11 @@ // and prevent commAppRouter and landingRouter from working correctly. So we // make sure that squadCalRouter goes last - // This endpoint should be handled by the mobile app. If the server - // receives this request, it means that the app is not installed and we - // should redirect the user to a place from which the app can be - // downloaded. It's important to define it before any other router so that - // it won't get handled by e.g. `/` rule. server.get('/invite/:secret', inviteResponder); if (landingBaseRoutePath) { const landingRouter = express.Router(); + landingRouter.get('/invite/:secret', inviteResponder); landingRouter.use('/images', express.static('images')); landingRouter.use('/fonts', express.static('fonts')); landingRouter.use( diff --git a/keyserver/src/responders/website-responders.js b/keyserver/src/responders/website-responders.js --- a/keyserver/src/responders/website-responders.js +++ b/keyserver/src/responders/website-responders.js @@ -608,6 +608,8 @@ const inviteSecretRegex = /^[a-z0-9]+$/i; +// On native, if this responder is called, it means that the app isn't +// installed. async function inviteResponder(req: $Request, res: $Response): Promise { const { secret } = req.params; const userAgent = req.get('User-Agent'); @@ -624,8 +626,10 @@ res.end(); return; } else if (detectionResult.os !== 'iOS') { - const baseRoutePath = getCommAppURLFacts()?.baseRoutePath; - const redirectUrl = `${baseRoutePath ?? '/'}handle/invite/${secret}`; + const urlFacts = getCommAppURLFacts(); + const baseDomain = urlFacts?.baseDomain ?? ''; + const basePath = urlFacts?.basePath ?? '/'; + const redirectUrl = `${baseDomain}${basePath}handle/invite/${secret}`; res.writeHead(301, { Location: redirectUrl, }); @@ -780,7 +784,10 @@
Download Comm - + Invite Link
diff --git a/native/android/app/src/main/AndroidManifest.xml b/native/android/app/src/main/AndroidManifest.xml --- a/native/android/app/src/main/AndroidManifest.xml +++ b/native/android/app/src/main/AndroidManifest.xml @@ -65,7 +65,9 @@ + android:host="comm.app" + android:pathPrefix="/invite" + /> development com.apple.developer.associated-domains - applinks:web.comm.app + applinks:comm.app com.apple.security.application-groups