diff --git a/apps/scan/src/app/api/x402/_handlers/registry-register-origin.ts b/apps/scan/src/app/api/x402/_handlers/registry-register-origin.ts index 582e4a4fd..07783509d 100644 --- a/apps/scan/src/app/api/x402/_handlers/registry-register-origin.ts +++ b/apps/scan/src/app/api/x402/_handlers/registry-register-origin.ts @@ -2,6 +2,7 @@ import type { registryRegisterOriginBodySchema } from '@/app/api/x402/_lib/schem import { jsonResponse } from '@/app/api/x402/_lib/utils'; import { fetchDiscoveryDocument } from '@/services/discovery'; import { registerResourcesFromDiscovery } from '@/lib/discovery/register-origin'; +import { revalidatePath } from 'next/cache'; import type { z } from 'zod'; @@ -30,6 +31,14 @@ export async function handleRegistryRegisterOrigin( discoveryResult.info ); + try { + if (result.originId) { + revalidatePath(`/server/${result.originId}`); + } + } catch (e) { + console.error('revalidatePath failed:', e); + } + if (result.registered === 0) { return jsonResponse( { diff --git a/apps/scan/src/app/api/x402/_handlers/registry-register.ts b/apps/scan/src/app/api/x402/_handlers/registry-register.ts index 5b0bca5f8..5937458b0 100644 --- a/apps/scan/src/app/api/x402/_handlers/registry-register.ts +++ b/apps/scan/src/app/api/x402/_handlers/registry-register.ts @@ -1,6 +1,7 @@ import type { registryRegisterBodySchema } from '@/app/api/x402/_lib/schemas'; import { jsonResponse } from '@/app/api/x402/_lib/utils'; import { registerEndpoint } from '@/lib/discovery/register-endpoint'; +import { revalidatePath } from 'next/cache'; import type { z } from 'zod'; export async function handleRegistryRegister( @@ -8,6 +9,14 @@ export async function handleRegistryRegister( ) { const result = await registerEndpoint(body.url); + try { + if (result.success && result.resource?.origin?.id) { + revalidatePath(`/server/${result.resource.origin.id}`); + } + } catch (e) { + console.error('revalidatePath failed:', e); + } + if (!result.success) { return jsonResponse(result, 422); } diff --git a/apps/scan/src/trpc/routers/public/resources.ts b/apps/scan/src/trpc/routers/public/resources.ts index e5457ae46..02b79e891 100644 --- a/apps/scan/src/trpc/routers/public/resources.ts +++ b/apps/scan/src/trpc/routers/public/resources.ts @@ -1,4 +1,5 @@ import z from 'zod'; +import { revalidatePath } from 'next/cache'; import { createTRPCRouter, @@ -138,7 +139,15 @@ export const resourcesRouter = createTRPCRouter({ }) ) .mutation(async ({ input }) => { - return await registerEndpoint(input.url.toString()); + const result = await registerEndpoint(input.url.toString()); + try { + if (result.success && result.resource?.origin?.id) { + revalidatePath(`/server/${result.resource.origin.id}`); + } + } catch (e) { + console.error('revalidatePath failed:', e); + } + return result; }), /** @@ -191,6 +200,14 @@ export const resourcesRouter = createTRPCRouter({ }; } + try { + if (result.originId) { + revalidatePath(`/server/${result.originId}`); + } + } catch (e) { + console.error('revalidatePath failed:', e); + } + return { success: true as const, ...result }; }),