diff --git a/src/backend/src/helpers.js b/src/backend/src/helpers.js index 7d16df64..f2194c61 100644 --- a/src/backend/src/helpers.js +++ b/src/backend/src/helpers.js @@ -299,6 +299,20 @@ async function refresh_associations_cache(){ const log = services.get('log-service').create('get_app'); let app = []; + + // This condition should be updated if the code below is re-ordered. + if ( options.follow_old_names && ! options.uid && options.name ) { + const svc_oldAppName = services.get('old-app-name'); + const old_name = await svc_oldAppName.check_app_name(options.name); + if ( old_name ) { + options.uid = old_name.app_uid; + + // The following line is technically pointless, but may avoid a bug + // if the if...else chain below is re-ordered. + delete options.name; + } + } + if(options.uid){ // try cache first app[0] = kv.get(`apps:uid:${options.uid}`); diff --git a/src/backend/src/routers/_default.js b/src/backend/src/routers/_default.js index 5a6071eb..c1fde620 100644 --- a/src/backend/src/routers/_default.js +++ b/src/backend/src/routers/_default.js @@ -341,7 +341,10 @@ router.all('*', async function(req, res, next) { // /app/ else if(path.startsWith('/app/')){ app_name = path.replace('/app/', ''); - const app = await get_app({name: app_name}); + const app = await get_app({ + follow_old_names: true, + name: app_name, + }); if(app){