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.
This commit is contained in:
Daniel Salazar authored and GitHub committed 2026-11-23 11:34:46 -07:00
1 parent 522c5af1a7
commit 5b8f4fb548
2 files changed
+91

No files matched your search

+9
View File
@@ -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 `<gui origin>/builtin/<name>` (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 })
@@ -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';