diff --git a/keyserver/.well-known/apple-app-site-association b/keyserver/.well-known/apple-app-site-association index 30ef3b091e..13b2b687f8 100644 --- 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 index 3793c3a196..84176770f1 100644 --- a/keyserver/src/keyserver.js +++ b/keyserver/src/keyserver.js @@ -109,6 +109,8 @@ import { 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 @@ import { // 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 index ff6b635212..c90753b82e 100644 --- a/keyserver/src/responders/website-responders.js +++ b/keyserver/src/responders/website-responders.js @@ -608,6 +608,8 @@ async function websiteResponder( 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 @@ async function inviteResponder(req: $Request, res: $Response): Promise { 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 @@ async function inviteResponder(req: $Request, res: $Response): Promise {
Download Comm - + Invite Link
diff --git a/native/android/app/src/main/AndroidManifest.xml b/native/android/app/src/main/AndroidManifest.xml index dc6f751e7a..9acb1b4baa 100644 --- 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