diff --git a/desktop/src/main.js b/desktop/src/main.js --- a/desktop/src/main.js +++ b/desktop/src/main.js @@ -22,7 +22,7 @@ } from './push-notifications.js'; const isDev = process.env.ENV === 'dev'; -const url = isDev ? 'http://localhost:3000/comm/' : 'https://web.comm.app'; +const url = isDev ? 'http://localhost:3000/webapp/' : 'https://web.comm.app'; const isMac = process.platform === 'darwin'; const scrollbarCSS = fs.promises.readFile( diff --git a/keyserver/icons/site.webmanifest b/keyserver/icons/site.webmanifest --- a/keyserver/icons/site.webmanifest +++ b/keyserver/icons/site.webmanifest @@ -3,12 +3,12 @@ "short_name": "SquadCal", "icons": [ { - "src": "/android-chrome-192x192.png", + "src": "android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" }, { - "src": "/android-chrome-512x512.png", + "src": "android-chrome-512x512.png", "sizes": "512x512", "type": "image/png" } diff --git a/keyserver/src/creators/report-creator.js b/keyserver/src/creators/report-creator.js --- a/keyserver/src/creators/report-creator.js +++ b/keyserver/src/creators/report-creator.js @@ -29,7 +29,7 @@ import { handleAsyncPromise } from '../responders/handlers.js'; import { createBotViewer } from '../session/bots.js'; import type { Viewer } from '../session/viewer.js'; -import { getAndAssertCommAppURLFacts } from '../utils/urls.js'; +import { getAndAssertKeyserverURLFacts } from '../utils/urls.js'; const { commbot } = bots; @@ -144,7 +144,7 @@ const { platform, codeVersion } = platformDetails; const platformString = codeVersion ? `${platform} v${codeVersion}` : platform; if (request.type === reportTypes.ERROR) { - const { baseDomain, basePath } = getAndAssertCommAppURLFacts(); + const { baseDomain, basePath } = getAndAssertKeyserverURLFacts(); return ( `${name} got an error :(\n` + `using ${platformString}\n` + diff --git a/keyserver/src/fetchers/upload-fetchers.js b/keyserver/src/fetchers/upload-fetchers.js --- a/keyserver/src/fetchers/upload-fetchers.js +++ b/keyserver/src/fetchers/upload-fetchers.js @@ -18,7 +18,7 @@ import { dbQuery, SQL } from '../database/database.js'; import type { Viewer } from '../session/viewer.js'; -import { getAndAssertCommAppURLFacts } from '../utils/urls.js'; +import { getAndAssertKeyserverURLFacts } from '../utils/urls.js'; type UploadInfo = { content: Buffer, @@ -104,7 +104,7 @@ } function getUploadURL(id: string, secret: string): string { - const { baseDomain, basePath } = getAndAssertCommAppURLFacts(); + const { baseDomain, basePath } = getAndAssertKeyserverURLFacts(); const uploadPath = `${basePath}upload/${id}/${secret}`; if (isDev) { const ipV4 = ip.v4.sync() || 'localhost'; diff --git a/keyserver/src/keyserver.js b/keyserver/src/keyserver.js --- a/keyserver/src/keyserver.js +++ b/keyserver/src/keyserver.js @@ -7,12 +7,14 @@ import cors from 'cors'; import crypto from 'crypto'; import express from 'express'; +import type { $Request, $Response } from 'express'; import expressWs from 'express-ws'; import os from 'os'; import qrcode from 'qrcode'; import './cron/cron.js'; import { qrCodeLinkURL } from 'lib/facts/links.js'; +import { isDev } from 'lib/utils/dev-utils.js'; import { migrate } from './database/migrations.js'; import { jsonEndpoints } from './endpoints.js'; @@ -44,9 +46,9 @@ import { getContentSigningKey } from './utils/olm-utils.js'; import { prefetchAllURLFacts, - getSquadCalURLFacts, + getKeyserverURLFacts, getLandingURLFacts, - getCommAppURLFacts, + getWebAppURLFacts, } from './utils/urls.js'; const shouldDisplayQRCodeInTerminal = false; @@ -54,18 +56,18 @@ (async () => { await Promise.all([olm.init(), prefetchAllURLFacts(), initENSCache()]); - const squadCalBaseRoutePath = getSquadCalURLFacts()?.baseRoutePath; + const keyserverBaseRoutePath = getKeyserverURLFacts()?.baseRoutePath; const landingBaseRoutePath = getLandingURLFacts()?.baseRoutePath; - const commAppURLFacts = getCommAppURLFacts(); - const commAppBaseRoutePath = commAppURLFacts?.baseRoutePath; + const webAppURLFacts = getWebAppURLFacts(); + const webAppBaseRoutePath = webAppURLFacts?.baseRoutePath; const compiledFolderOptions = process.env.NODE_ENV === 'development' ? undefined : { maxAge: '1y', immutable: true }; - const corsOptions = commAppURLFacts - ? { origin: commAppURLFacts.baseDomain, methods: ['GET', 'POST'] } + const corsOptions = webAppURLFacts + ? { origin: webAppURLFacts.baseDomain, methods: ['GET', 'POST'] } : null; const isCPUProfilingEnabled = process.env.KEYSERVER_CPU_PROFILING_ENABLED; @@ -225,16 +227,25 @@ server.use(landingBaseRoutePath, landingRouter); } - if (commAppBaseRoutePath) { + if (webAppBaseRoutePath) { const commAppRouter = express.Router(); setupAppRouter(commAppRouter); - server.use(commAppBaseRoutePath, commAppRouter); + server.use(webAppBaseRoutePath, commAppRouter); } - if (squadCalBaseRoutePath) { + if (keyserverBaseRoutePath) { const squadCalRouter = express.Router(); setupAppRouter(squadCalRouter); - server.use(squadCalBaseRoutePath, squadCalRouter); + server.use(keyserverBaseRoutePath, squadCalRouter); + } + + if (isDev && webAppURLFacts) { + const oldPath = '/comm/'; + server.all(`${oldPath}*`, (req: $Request, res: $Response) => { + const endpoint = req.url.slice(oldPath.length); + const newURL = `${webAppURLFacts.baseDomain}${webAppURLFacts.basePath}${endpoint}`; + res.redirect(newURL); + }); } const listenAddress = (() => { 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 @@ -15,8 +15,9 @@ import { waitForStream } from '../utils/json-stream.js'; import { + getAndAssertKeyserverURLFacts, getAppURLFactsFromRequestURL, - getCommAppURLFacts, + getWebAppURLFacts, } from '../utils/urls.js'; const { renderToNodeStream } = ReactDOMServer; @@ -110,9 +111,18 @@ } } +function stripLastSlash(input: string): string { + return input.replace(/\/$/, ''); +} + async function websiteResponder(req: $Request, res: $Response): Promise { const { basePath } = getAppURLFactsFromRequestURL(req.originalUrl); - const baseURL = basePath.replace(/\/$/, ''); + const baseURL = stripLastSlash(basePath); + + const keyserverURLFacts = getAndAssertKeyserverURLFacts(); + const keyserverURL = `${keyserverURLFacts.baseDomain}${stripLastSlash( + keyserverURLFacts.basePath, + )}`; const loadingPromise = getWebpackCompiledRootComponentForSSR(); @@ -171,6 +181,7 @@ res.end(html`