### Task 9: Toggle "Mostra tag" — endpoint cookie e cablaggio **Files:** - Create: `src/pages/api/admin/showtags.ts` - Modify: `src/components/Header.astro` (script del pulsante) **Interfaces:** - Consumes: `locals.user` dal middleware (rotta sotto `/api/admin`, quindi login garantito). - Produces: `POST /api/admin/showtags` con body `{ on: boolean }`; imposta/rimuove il cookie `showtags`; `403` se il ruolo non è `superuser`/`admin`. - [ ] **Step 1: Crea l'endpoint** Crea `src/pages/api/admin/showtags.ts`: ```typescript import type { APIRoute } from 'astro'; export const prerender = false; const json = (status: number, body: object) => new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } }); export const POST: APIRoute = async ({ request, cookies, locals }) => { const role = locals.user!.role; if (role !== 'superuser' && role !== 'admin') return json(403, { error: 'Permessi insufficienti' }); let data: { on?: unknown }; try { data = await request.json(); } catch { return json(400, { error: 'Dati non validi.' }); } if (data.on) { cookies.set('showtags', '1', { httpOnly: true, sameSite: 'lax', path: '/', secure: import.meta.env.PROD }); } else { cookies.delete('showtags', { path: '/' }); } return json(200, { on: Boolean(data.on) }); }; ``` - [ ] **Step 2: Cabla il pulsante nell'header** In `src/components/Header.astro`, dentro il blocco `