diff --git a/keyserver/src/database/migration-config.js b/keyserver/src/database/migration-config.js --- a/keyserver/src/database/migration-config.js +++ b/keyserver/src/database/migration-config.js @@ -57,8 +57,8 @@ ALTER TABLE users DROP COLUMN IF EXISTS public_key, MODIFY hash char(60) COLLATE utf8mb4_bin DEFAULT NULL; - - ALTER TABLE sessions + + ALTER TABLE sessions DROP COLUMN IF EXISTS public_key; `, { multipleStatements: true }, @@ -110,13 +110,21 @@ async () => { const time = Date.now(); await dbQuery(SQL` - INSERT IGNORE INTO policy_acknowledgments (policy, user, date, + INSERT IGNORE INTO policy_acknowledgments (policy, user, date, confirmed) SELECT ${policyTypes.tosAndPrivacyPolicy}, id, ${time}, 1 FROM users `); }, ], + [ + 12, + async () => { + moveToNonApacheConfig('facts/squadcal_url.json', '/', 'apache'); + moveToNonApacheConfig('facts/commapp_url.json', '/comm/', 'none'); + moveToNonApacheConfig('facts/landing_url.json', '/commlanding/', 'none'); + }, + ], ]); const newDatabaseVersion: number = Math.max(...migrations.keys()); @@ -175,4 +183,29 @@ await writeFile.close(); } +async function moveToNonApacheConfig( + filePath: string, + routePath: string, + proxy: string, +): Promise { + if (process.env.COMM_DATABASE_HOST) { + console.warn( + `production environment has been detected, avoid updating ${filePath}`, + ); + return; + } + // Since the non-apache config is so opionated, just write expected config + const newJSON = { + baseDomain: 'http://localhost:3000', + basePath: routePath, + baseRoutePath: routePath, + https: false, + proxy: proxy, + }; + console.warn(`updating ${filePath} to ${JSON.stringify(newJSON)}`); + const writeFile = await fs.promises.open(filePath, 'w'); + await writeFile.writeFile(JSON.stringify(newJSON, null, ' '), 'utf8'); + await writeFile.close(); +} + export { migrations, newDatabaseVersion }; diff --git a/native/utils/url-utils.js b/native/utils/url-utils.js --- a/native/utils/url-utils.js +++ b/native/utils/url-utils.js @@ -26,11 +26,11 @@ } function getDevNodeServerURLFromHostname(hostname: string): string { - return `http://${hostname}/comm`; + return `http://${hostname}:3000/comm`; } function getDevLandingURLFromHostname(hostname: string): string { - return `http://${hostname}/commlanding`; + return `http://${hostname}:3000/commlanding`; } function getDevNodeServerURL(): string {