fix(scans): rafraîchit l'historique et l'inventaire après un scan
L'historique des scans ne se mettait pas à jour après un POST sur /api/discovery : le Server Component restait servi depuis le cache route de Next. - discovery-launcher : appelle router.refresh() après un scan réussi pour invalider le cache et re-rendre la page parent. - scans/page.tsx + hosts/page.tsx : déclare `dynamic = 'force-dynamic'` et `revalidate = 0`. Sans ça, Next pouvait statifier ces routes au build (mode standalone) puisque la fonction getX() ne fait pas appel à un signal dynamique. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,10 @@ import {
|
||||
} from '@/components/ui/table';
|
||||
import { prisma } from '@/lib/db/prisma';
|
||||
|
||||
// L'inventaire évolue à chaque scan : pas de cache de route
|
||||
export const dynamic = 'force-dynamic';
|
||||
export const revalidate = 0;
|
||||
|
||||
async function getHosts() {
|
||||
try {
|
||||
return await prisma.host.findMany({
|
||||
|
||||
@@ -15,6 +15,10 @@ import {
|
||||
import { DiscoveryLauncher } from '@/components/scans/discovery-launcher';
|
||||
import { prisma } from '@/lib/db/prisma';
|
||||
|
||||
// L'historique change à chaque scan : pas de cache de route
|
||||
export const dynamic = 'force-dynamic';
|
||||
export const revalidate = 0;
|
||||
|
||||
async function getScans() {
|
||||
try {
|
||||
return await prisma.scan.findMany({
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { Radar, Zap } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -10,6 +11,7 @@ import { Card } from '@/components/ui/card';
|
||||
type Kind = 'full' | 'ping' | 'port' | 'arp' | 'mdns';
|
||||
|
||||
export function DiscoveryLauncher() {
|
||||
const router = useRouter();
|
||||
const [kind, setKind] = useState<Kind>('full');
|
||||
const [cidr, setCidr] = useState('192.168.1.0/24');
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -37,6 +39,8 @@ export function DiscoveryLauncher() {
|
||||
setMessage(
|
||||
`✓ Scan ${json.data.status} — ${json.data.hostsFound} hôtes, ${json.data.portsFound} ports`,
|
||||
);
|
||||
// Invalide le cache route pour que l'historique se rafraîchisse
|
||||
router.refresh();
|
||||
} catch (e) {
|
||||
setMessage(`✕ ${(e as Error).message}`);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user