From 5b8f4fb5483891c656d7ba2277fd179b0706dba7 Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Mon, 23 Nov 2026 11:34:46 -0700 Subject: [PATCH] fix(apps): accept the Dev Center new-app placeholder as an index_url (#4757) apps.create and apps.update refuse an index_url on the host of a godmode app. Dev Center points every new app at https://console.puter.com/coming-soon.html until its first deploy, and that page is on Dev Center's own host. That exact URL is now accepted. Any other URL on the host, including the placeholder with a query string or fragment, is still refused. --- src/backend/drivers/apps/AppDriver.js | 9 +++ src/backend/drivers/apps/AppDriver.test.ts | 82 ++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/src/backend/drivers/apps/AppDriver.js b/src/backend/drivers/apps/AppDriver.js index a0194806c..f937b9c0a 100644 --- a/src/backend/drivers/apps/AppDriver.js +++ b/src/backend/drivers/apps/AppDriver.js @@ -95,6 +95,12 @@ const INDEX_URL_UNIQUENESS_EXEMPTION_CANDIDATES = [ 'https://dev-center.puter.com/coming-soon', ]; +// Static page Dev Center points a new app at until its first deploy. It +// sits on Dev Center's own host, so the godmode-host check lets this exact +// URL through. +const NEW_APP_PLACEHOLDER_INDEX_URL = + 'https://console.puter.com/coming-soon.html'; + // Sentinel host for builtin apps. The GUI rewrites index_urls on this // host to `/builtin/` (see launchApp.js), so rows // carrying it are reserved for migration-seeded builtins — a user app @@ -1049,6 +1055,9 @@ export class AppDriver extends PuterDriver { /** A godmode app whose origin `indexUrl` would share. */ #findGodmodeHostApp(indexUrl, excludeAppId) { + if (indexUrl === NEW_APP_PLACEHOLDER_INDEX_URL) { + return Promise.resolve(null); + } const host = URL.parse(indexUrl)?.host; return host ? this.appStore.findGodmodeOnHost(host, { excludeAppId }) diff --git a/src/backend/drivers/apps/AppDriver.test.ts b/src/backend/drivers/apps/AppDriver.test.ts index 70fd9344d..adadd1ce4 100644 --- a/src/backend/drivers/apps/AppDriver.test.ts +++ b/src/backend/drivers/apps/AppDriver.test.ts @@ -277,6 +277,88 @@ describe('AppDriver.create', () => { }); }); + describe('with a godmode app on the new-app placeholder host', () => { + const placeholder = 'https://console.puter.com/coming-soon.html'; + + beforeAll(async () => { + const { actor } = await makeUser(); + const app = await withActor(actor, () => + driver.create({ + object: { + name: uniqueName('placeholder-host'), + title: 't', + index_url: 'https://console.puter.com/', + }, + }), + ); + await server.clients.db.write( + 'UPDATE `apps` SET `godmode` = 1 WHERE `uid` = ?', + [app.uid], + ); + }); + + it('lets several users create apps on the placeholder URL', async () => { + for (let i = 0; i < 2; i++) { + const { actor } = await makeUser(); + await expect( + withActor(actor, () => + driver.create({ + object: { + name: uniqueName('placeholder'), + title: 't', + index_url: placeholder, + }, + }), + ), + ).resolves.toMatchObject({ index_url: placeholder }); + } + }); + + it('lets an app move back to the placeholder URL', async () => { + const { actor } = await makeUser(); + const created = await withActor(actor, () => + driver.create({ + object: { + name: uniqueName('placeholder-upd'), + title: 't', + index_url: uniqueIndexUrl(), + }, + }), + ); + await expect( + withActor(actor, () => + driver.update({ + uid: created.uid, + object: { index_url: placeholder }, + }), + ), + ).resolves.toMatchObject({ index_url: placeholder }); + }); + + it.each([ + ['with a query string', `${placeholder}?puter.api_origin=x`], + ['with a fragment', `${placeholder}#x`], + ['over http', 'http://console.puter.com/coming-soon.html'], + ['on another path', 'https://console.puter.com/index.html'], + ])('rejects the placeholder host %s with 400', async (_label, index_url) => { + const { actor } = await makeUser(); + await expect( + withActor(actor, () => + driver.create({ + object: { + name: uniqueName('placeholder-variant'), + title: 't', + index_url, + }, + }), + ), + ).rejects.toMatchObject({ + statusCode: 400, + message: /system host/, + }); + }); + }); + describe('with a claimed subdomain', () => { const claimed = 'claimed-app-host';