diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts
index 4c77b74..0a6f06d 100644
--- a/apps/web/next.config.ts
+++ b/apps/web/next.config.ts
@@ -7,6 +7,11 @@ const rootEnv = new URL('../../.env.local', import.meta.url);
if (existsSync(rootEnv)) process.loadEnvFile(rootEnv);
const nextConfig: NextConfig = {
+ // Every report page has a JSON twin at the same address plus .json. Domains have dots, so it
+ // can't be its own [domain] segment: it's rewritten to a route handler instead.
+ async rewrites() {
+ return [{ source: '/s/:domain(.+)\\.json', destination: '/api/reports/:domain' }];
+ },
// The workspace packages ship TypeScript source, so Next compiles them like app code.
// Only loaded when self-hosted with Chromium installed; never bundled.
serverExternalPackages: ['playwright-core'],
diff --git a/apps/web/src/app/api/reports/[domain]/route.ts b/apps/web/src/app/api/reports/[domain]/route.ts
new file mode 100644
index 0000000..3a8cb2f
--- /dev/null
+++ b/apps/web/src/app/api/reports/[domain]/route.ts
@@ -0,0 +1,10 @@
+import { reportJson } from '../../../../lib/report-json.ts';
+import { getStore } from '../../../../lib/services.ts';
+
+// /s/.json lands here (see next.config.ts): the report page's JSON twin.
+export async function GET(request: Request, { params }: { params: Promise<{ domain: string }> }) {
+ const domain = decodeURIComponent((await params).domain).toLowerCase();
+ const scan = await getStore().latestScan(domain);
+ const { status, body, headers } = reportJson(domain, scan, new URL(request.url).origin);
+ return Response.json(body, { status, headers });
+}
diff --git a/apps/web/src/app/globals.css b/apps/web/src/app/globals.css
index 4a59c19..94c5eb8 100644
--- a/apps/web/src/app/globals.css
+++ b/apps/web/src/app/globals.css
@@ -650,6 +650,14 @@ details[open] > .tech-row {
display: contents;
}
+.json-link {
+ align-self: center;
+ margin-right: var(--space-2);
+ font-family: var(--font-mono);
+ font-size: var(--text-data);
+ color: var(--ink-3);
+}
+
.warn-text {
color: var(--warn-ink);
}
@@ -818,6 +826,12 @@ details[open] > .tech-row {
grid-template-columns: 1fr 1fr;
}
+ .json-link {
+ grid-column: 1 / -1;
+ align-self: start;
+ margin: 0 0 var(--space-1);
+ }
+
.actions .button {
width: 100%;
height: var(--control-md);
diff --git a/apps/web/src/app/s/[domain]/page.tsx b/apps/web/src/app/s/[domain]/page.tsx
index 82b9c14..3bd9918 100644
--- a/apps/web/src/app/s/[domain]/page.tsx
+++ b/apps/web/src/app/s/[domain]/page.tsx
@@ -9,8 +9,12 @@ interface Props {
}
export async function generateMetadata({ params }: Props): Promise {
- const { domain } = await params;
- return { title: `${decodeURIComponent(domain)} · stackprobe` };
+ const name = decodeURIComponent((await params).domain).toLowerCase();
+ return {
+ title: `${name} · stackprobe`,
+ // Agents can find the report as data from the page itself.
+ alternates: { types: { 'application/json': `/s/${encodeURIComponent(name)}.json` } },
+ };
}
export default async function ScanPage({ params, searchParams }: Props) {
diff --git a/apps/web/src/app/s/[domain]/report-sections.test.tsx b/apps/web/src/app/s/[domain]/report-sections.test.tsx
index 77d034b..7bc0173 100644
--- a/apps/web/src/app/s/[domain]/report-sections.test.tsx
+++ b/apps/web/src/app/s/[domain]/report-sections.test.tsx
@@ -127,10 +127,13 @@ describe('ReportView', () => {
expect(html).not.toContain('framer header');
});
- test('says which checks ran and offers copy and scan again', () => {
+ test('says which checks ran and offers the JSON twin, copy and scan again', () => {
const html = render();
expect(html).toContain('Checks that ran: HTTP and a real browser.');
expect(html).toContain('Fingerprints abc123');
+ expect(html).toContain(
+ 'acme.test.json',
+ );
expect(html).toContain('Copy link');
expect(html).toContain('Scan again');
});
diff --git a/apps/web/src/app/s/[domain]/report-sections.tsx b/apps/web/src/app/s/[domain]/report-sections.tsx
index b727b30..4fbf6f8 100644
--- a/apps/web/src/app/s/[domain]/report-sections.tsx
+++ b/apps/web/src/app/s/[domain]/report-sections.tsx
@@ -141,6 +141,13 @@ export function ReportView({