From a86bee443bbc45f96060cdd762c402a165e78938 Mon Sep 17 00:00:00 2001 From: Zakaria Date: Sat, 24 Oct 2026 14:25:35 -0400 Subject: [PATCH] fix(api): show CloudFront distributions at .cloudfront.localhost Distributions were linked under localhost.floci.io, another project's domain. Every .localhost name resolves to the machine itself, so the brand-neutral .cloudfront.localhost reaches the runtime with no DNS or hosts entry. --- packages/api/src/adapter-aws/AwsCdnAdapter.test.ts | 2 +- packages/api/src/adapter-aws/AwsCdnAdapter.ts | 7 ++++--- packages/frontend/src/components/CloudFrontPanel.test.tsx | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/api/src/adapter-aws/AwsCdnAdapter.test.ts b/packages/api/src/adapter-aws/AwsCdnAdapter.test.ts index a219955..6345409 100644 --- a/packages/api/src/adapter-aws/AwsCdnAdapter.test.ts +++ b/packages/api/src/adapter-aws/AwsCdnAdapter.test.ts @@ -56,7 +56,7 @@ describe('AwsCdnAdapter distributions', () => { const [listed] = await cdn.list() expect(listed).toMatchObject({id: ID, name: 'e7cpm0p0g0vc8d.cloudfront.net', status: 'Deployed'}) - expect(listed.metadata).toMatchObject({viewerUrl: 'http://e7cpm0p0g0vc8d.cloudfront.localhost.floci.io:4566/', enabled: true, comment: 'Docs site', originDomains: ['site.s3.amazonaws.com']}) + expect(listed.metadata).toMatchObject({viewerUrl: 'http://e7cpm0p0g0vc8d.cloudfront.localhost:4566/', enabled: true, comment: 'Docs site', originDomains: ['site.s3.amazonaws.com']}) expect(await cdn.list({search: 'site.s3'})).toHaveLength(1) expect(await cdn.list({search: 'nothing'})).toHaveLength(0) }) diff --git a/packages/api/src/adapter-aws/AwsCdnAdapter.ts b/packages/api/src/adapter-aws/AwsCdnAdapter.ts index 9577106..6826c4d 100644 --- a/packages/api/src/adapter-aws/AwsCdnAdapter.ts +++ b/packages/api/src/adapter-aws/AwsCdnAdapter.ts @@ -46,8 +46,9 @@ const RECENT_INVALIDATIONS = 5 * - `DeleteDistribution` refuses an enabled distribution with `DistributionNotDisabled` * (409), as on AWS, so delete disables it first. * - A missing distribution is `NoSuchDistribution` with HTTP 404. - * - Viewer requests reach a distribution at `{id}.cloudfront.localhost.floci.io` on the - * runtime's port, a name that resolves to 127.0.0.1 without any hosts-file entry. + * - Viewer requests reach a distribution at `{id}.cloudfront.localhost` on the runtime's + * port. Browsers and curl resolve every `.localhost` name to the machine itself (RFC 6761), + * so no DNS or hosts-file entry is needed. */ export class AwsCdnAdapter implements CloudServiceAdapter { readonly cloud = 'aws' as const @@ -246,7 +247,7 @@ export class AwsCdnAdapter implements CloudServiceAdapter { /** Where a browser on this machine reaches the distribution through the runtime. */ private viewerUrl(id: string): string { const port = new URL(this.endpoint).port || '4566' - return `http://${id.toLowerCase()}.cloudfront.localhost.floci.io:${port}/` + return `http://${id.toLowerCase()}.cloudfront.localhost:${port}/` } } diff --git a/packages/frontend/src/components/CloudFrontPanel.test.tsx b/packages/frontend/src/components/CloudFrontPanel.test.tsx index 221cf47..5510f91 100644 --- a/packages/frontend/src/components/CloudFrontPanel.test.tsx +++ b/packages/frontend/src/components/CloudFrontPanel.test.tsx @@ -14,7 +14,7 @@ const api = vi.hoisted(() => ({ vi.mock('@/api/cloudProxyClient', () => api) vi.mock('@/lib/accountStore', () => ({useAccountId: () => '000000000000'})) -const VIEWER_URL = 'http://e7cpm0p0g0vc8d.cloudfront.localhost.floci.io:4566/' +const VIEWER_URL = 'http://e7cpm0p0g0vc8d.cloudfront.localhost:4566/' const distribution: CloudResource = { id: 'E7CPM0P0G0VC8D', name: 'e7cpm0p0g0vc8d.cloudfront.net', cloud: 'aws', service: 'cdn', type: 'distribution', region: null, createdAt: null, status: 'Deployed',