Add revalidatePath('/', 'layout') calls to gallery save, settings save,
and reload routes. This tells Next.js to purge any cached page responses
so the next browser refresh picks up the new hero images and config.
22 lines
742 B
TypeScript
22 lines
742 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import { revalidatePath } from 'next/cache';
|
|
import { isAdminAuthenticated, isAdminEnabled } from '@/lib/admin/auth';
|
|
import { invalidateConfigCache } from '@/lib/config';
|
|
import { immich } from '@/lib/immich';
|
|
|
|
/** POST: Force reload config and clear caches. */
|
|
export async function POST() {
|
|
if (!isAdminEnabled()) {
|
|
return NextResponse.json({ error: 'Admin not enabled' }, { status: 403 });
|
|
}
|
|
if (!(await isAdminAuthenticated())) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
}
|
|
|
|
invalidateConfigCache();
|
|
immich.invalidateAll();
|
|
revalidatePath('/', 'layout');
|
|
|
|
return NextResponse.json({ success: true, message: 'Config and cache reloaded' });
|
|
}
|