Hub 2.10.0: emails laid out as Events' and Accounts'; FastPanel ^~ /api/

- src/utils/emailLayout.js: one layout for every Hub email (Cross Code
  header with the logo, heading, button with the link under it, notes,
  tables, job steps, code blocks, footer), HTML and plain text from the
  same blocks, everything escaped. mail.sendMail attaches the logo.
- Every email moved onto it: job reports, alerts, update requests, the
  SMTP test, notices, and all emails to site admins. Billing keeps its own.
- The FastPanel email and the install page give the backend as nginx config
  with location ^~ /api/ (FastPanel's static-file rule took /api/...png).
- Proxy done checks /api/proxy-check.png doesn't reach the frontend.
- deployment.md: ^~ for the Hub's own /api/ too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 14:40:55 +02:00
co-authored by Claude Opus 5.5
parent 92b61f0d0d
commit 14dd608e37
16 changed files with 685 additions and 87 deletions
+27 -2
View File
@@ -145,8 +145,33 @@ describe('jobs', () => {
expect(await db.deployment.findUnique({ where: { id: deployment.id } })).toMatchObject({ status: 'waiting_for_proxy', version: '2.4.0' });
expect(await db.job.findFirst({ where: { serverId: central.id, type: 'check-ports' } })).toMatchObject({ args: { ports: [20000, 20001] } });
const mail = mockMails.find(m => m.subject.includes('Installed: hope'));
expect(mail.text).toContain('/api → http://127.0.0.1:20001');
expect(mail.text).toContain('everything else → http://127.0.0.1:20000');
// 2.10.0: the backend location is ^~, so FastPanel's static-file rule can't take /api/…/logo.png.
expect(mail.text).toContain('location ^~ /api/ {');
expect(mail.text).toContain('proxy_pass http://127.0.0.1:20001;');
expect(mail.text).toContain('as a proxy to http://127.0.0.1:20000 (the frontend)');
expect(mail.html).toContain('location ^~ /api/ {');
expect(mail.html).toContain('href="https://hub.test/servers/installs/');
expect(await jobs.fastPanelText(await db.deployment.findUnique({ where: { id: deployment.id } }))).toContain(' location ^~ /api/ {');
});
test('Proxy done refuses a site whose /api paths with a file extension reach the frontend', async () => {
const { server } = await joinServer();
await servers.setServerConfig(server.id, { TRUST_PROXY: 'loopback' });
const { deployment } = await jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.hope.co.za', adminName: 'Jane', adminEmail: 'jane@hope.test' }, admin, NOW);
const answer = (status, poweredBy, json) => ({ status, headers: new Headers(poweredBy ? { 'x-powered-by': poweredBy } : {}), json: async () => json });
const site = frontendTakesFiles => async url => {
if (url.endsWith('/api/health')) return answer(200, 'Express', { version: null });
if (url.includes('/api/proxy-check.png')) return answer(404, frontendTakesFiles ? 'Next.js' : 'Express');
return answer(200, 'Next.js');
};
const refused = await jobs.proxyDone(deployment.id, NOW, site(true));
expect(refused.live).toBe(false);
expect(refused.problems.join(' ')).toContain('location ^~ /api/');
const ok = await jobs.proxyDone(deployment.id, NOW, site(false));
expect(ok).toEqual({ live: true, problems: [] });
const ready = mockMails.find(m => m.subject.includes('site is ready'));
expect(ready.html).toContain('href="https://events.hope.co.za/setup"');
expect(ready.text).toContain('Start the setup: https://events.hope.co.za/setup');
});
test('a failed install frees its ports again', async () => {