diff --git a/keyserver/src/keyserver.js b/keyserver/src/keyserver.js --- a/keyserver/src/keyserver.js +++ b/keyserver/src/keyserver.js @@ -109,12 +109,6 @@ downloadHandler(uploadDownloadResponder), ); - // 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. - 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); @@ -147,6 +141,12 @@ server.use(landingBaseRoutePath, landingRouter); } + // 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. + server.get('/invite/:secret', inviteResponder); + if (commAppBaseRoutePath) { const commAppRouter = express.Router(); setupAppRouter(commAppRouter); 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 @@ -61,7 +61,10 @@ import { setNewSession } from '../session/cookies.js'; import { Viewer } from '../session/viewer.js'; import { streamJSON, waitForStream } from '../utils/json-stream.js'; -import { getAppURLFactsFromRequestURL } from '../utils/urls.js'; +import { + getAppURLFactsFromRequestURL, + getCommAppURLFacts, +} from '../utils/urls.js'; import { validateOutput } from '../utils/validation-utils.js'; const { renderToNodeStream } = ReactDOMServer; @@ -569,6 +572,14 @@ }); res.end(); return; + } else if (detectionResult.os !== 'iOS') { + const baseRoutePath = getCommAppURLFacts()?.baseRoutePath; + const redirectUrl = `${baseRoutePath ?? '/'}handle/invite/${secret}`; + res.writeHead(301, { + Location: redirectUrl, + }); + res.end(); + return; } const fontsURL = await getFontsURL(); res.end(html`