diff --git a/docs/dev_environment.md b/docs/dev_environment.md --- a/docs/dev_environment.md +++ b/docs/dev_environment.md @@ -498,7 +498,7 @@ { "baseDomain": "http://localhost", "basePath": "/comm/", - "baseRoutePath": "/comm/", + "baseRoutePath": "/", "https": false } ``` diff --git a/server/src/database/migrations.js b/server/src/database/migrations.js --- a/server/src/database/migrations.js +++ b/server/src/database/migrations.js @@ -30,6 +30,22 @@ await writeFile.close(); } +async function fixBaseRoutePathForLocalhost(filePath: string): Promise { + const readFile = await fs.promises.open(filePath, 'r'); + const contents = await readFile.readFile('utf8'); + let json = JSON.parse(contents); + await readFile.close(); + if (json.baseDomain !== 'http://localhost') { + return; + } + const baseRoutePath = '/'; + json = { ...json, baseRoutePath }; + console.warn(`updating ${filePath} to ${JSON.stringify(json)}`); + const writeFile = await fs.promises.open(filePath, 'w'); + await writeFile.writeFile(JSON.stringify(json, null, ' '), 'utf8'); + await writeFile.close(); +} + const migrations: $ReadOnlyMap Promise> = new Map([ [ 0, @@ -46,6 +62,13 @@ } catch {} }, ], + [ + 2, + async () => { + await fixBaseRoutePathForLocalhost('facts/commapp_url.json'); + await fixBaseRoutePathForLocalhost('facts/squadcal_url.json'); + }, + ], ]); async function migrate(): Promise {