Riduce il routing del contact form pubblico a info, privacy e careers.

Allinea backend, configurazione env e documentazione al nuovo modello vetrina con destinatari meno granulari.

Made-with: Cursor
This commit is contained in:
Javaxman
2026-04-24 21:32:15 +02:00
parent f33d29fe7b
commit ddab32d3ef
4 changed files with 24 additions and 24 deletions

View File

@ -7,10 +7,7 @@ CONTACT_FORM_MODE=dev
CONTACT_FORM_RESEND_API_KEY= CONTACT_FORM_RESEND_API_KEY=
CONTACT_FORM_FROM_EMAIL=no-reply@nexstudio.com CONTACT_FORM_FROM_EMAIL=no-reply@nexstudio.com
CONTACT_FORM_TO_EMAIL=info@nexstudio.com CONTACT_FORM_TO_EMAIL=info@nexstudio.com
CONTACT_FORM_TO_EMAIL_SUPPORT=support@nexstudio.com CONTACT_FORM_TO_EMAIL_INFO=info@nexstudio.com
CONTACT_FORM_TO_EMAIL_PRIVACY= CONTACT_FORM_TO_EMAIL_PRIVACY=
CONTACT_FORM_TO_EMAIL_SECURITY= CONTACT_FORM_TO_EMAIL_CAREERS=
CONTACT_FORM_TO_EMAIL_ETHICS=
CONTACT_FORM_TO_EMAIL_LEGAL=
CONTACT_FORM_TO_EMAIL_HR=
CONTACT_TURNSTILE_SECRET_KEY= CONTACT_TURNSTILE_SECRET_KEY=

View File

@ -66,12 +66,9 @@ Variabili server (Cloudflare/local):
- `CONTACT_FORM_RESEND_API_KEY` - `CONTACT_FORM_RESEND_API_KEY`
- `CONTACT_FORM_FROM_EMAIL` (consigliato: `no-reply@nexstudio.ai`) - `CONTACT_FORM_FROM_EMAIL` (consigliato: `no-reply@nexstudio.ai`)
- `CONTACT_FORM_TO_EMAIL` (default destinatario, es. `info@nexstudio.ai`) - `CONTACT_FORM_TO_EMAIL` (default destinatario, es. `info@nexstudio.ai`)
- `CONTACT_FORM_TO_EMAIL_SUPPORT` - `CONTACT_FORM_TO_EMAIL_INFO` (opzionale, override esplicito per area "info")
- `CONTACT_FORM_TO_EMAIL_PRIVACY` - `CONTACT_FORM_TO_EMAIL_PRIVACY`
- `CONTACT_FORM_TO_EMAIL_SECURITY` - `CONTACT_FORM_TO_EMAIL_CAREERS`
- `CONTACT_FORM_TO_EMAIL_ETHICS`
- `CONTACT_FORM_TO_EMAIL_LEGAL`
- `CONTACT_FORM_TO_EMAIL_HR`
- `CONTACT_TURNSTILE_SECRET_KEY` - `CONTACT_TURNSTILE_SECRET_KEY`
Comportamento: Comportamento:
@ -79,6 +76,19 @@ Comportamento:
- `dev`: accetta submit e scrive payload nei log (senza invio reale) - `dev`: accetta submit e scrive payload nei log (senza invio reale)
- `live`: valida Turnstile e invia email via Resend - `live`: valida Turnstile e invia email via Resend
Routing pubblico consigliato (portale vetrina):
- `info`: informazioni generali/commerciali
- `privacy`: richieste privacy e diritti interessato
- `careers`: candidature e collaborazioni
Indirizzi consigliati portale:
- `info@nexstudio.ai`
- `privacy@nexstudio.ai`
- `careers@nexstudio.ai`
- `no-reply@nexstudio.ai` (solo invio comunicazioni/newsletter, non destinazione inbound)
## Deploy Cloudflare ## Deploy Cloudflare
Impostazioni consigliate: Impostazioni consigliate:

View File

@ -30,7 +30,7 @@ export const cta = {
nameLabel: 'Nome', nameLabel: 'Nome',
companyLabel: 'Azienda (opzionale)', companyLabel: 'Azienda (opzionale)',
countryLabel: 'Paese', countryLabel: 'Paese',
departmentLabel: 'Reparto', departmentLabel: 'Area',
emailLabel: 'Email', emailLabel: 'Email',
messageLabel: 'Scrivi qui il tuo messaggio', messageLabel: 'Scrivi qui il tuo messaggio',
submitLabel: 'Invia messaggio', submitLabel: 'Invia messaggio',
@ -54,13 +54,9 @@ export const cta = {
fieldEmail: 'email', fieldEmail: 'email',
fieldMessage: 'message', fieldMessage: 'message',
departmentOptions: [ departmentOptions: [
{ value: 'general', label: 'Generale' }, { value: 'info', label: 'Informazioni generali e commerciali' },
{ value: 'support', label: 'Support' }, { value: 'privacy', label: 'Privacy' },
{ value: 'privacy', label: 'Privacy / DPO' }, { value: 'careers', label: 'Careers / Collaborazioni' },
{ value: 'security', label: 'Security / Incident Response' },
{ value: 'ethics', label: 'Segnalazioni confidenziali (Ethics)' },
{ value: 'legal', label: 'Legal' },
{ value: 'hr', label: 'HR' },
], ],
}, },
} as const; } as const;

View File

@ -82,12 +82,9 @@ async function sendWithResend(apiKey: string, fromEmail: string, toEmail: string
function resolveDepartmentRecipient(runtimeEnv: RuntimeEnv, defaultRecipient: string, department: string): string { function resolveDepartmentRecipient(runtimeEnv: RuntimeEnv, defaultRecipient: string, department: string): string {
const normalized = department.trim().toLowerCase(); const normalized = department.trim().toLowerCase();
const map: Record<string, string> = { const map: Record<string, string> = {
support: readEnv('CONTACT_FORM_TO_EMAIL_SUPPORT', runtimeEnv), info: readEnv('CONTACT_FORM_TO_EMAIL_INFO', runtimeEnv) || defaultRecipient,
privacy: readEnv('CONTACT_FORM_TO_EMAIL_PRIVACY', runtimeEnv), privacy: readEnv('CONTACT_FORM_TO_EMAIL_PRIVACY', runtimeEnv),
security: readEnv('CONTACT_FORM_TO_EMAIL_SECURITY', runtimeEnv), careers: readEnv('CONTACT_FORM_TO_EMAIL_CAREERS', runtimeEnv),
ethics: readEnv('CONTACT_FORM_TO_EMAIL_ETHICS', runtimeEnv),
legal: readEnv('CONTACT_FORM_TO_EMAIL_LEGAL', runtimeEnv),
hr: readEnv('CONTACT_FORM_TO_EMAIL_HR', runtimeEnv),
}; };
return map[normalized] || defaultRecipient; return map[normalized] || defaultRecipient;
} }
@ -111,7 +108,7 @@ export const POST: APIRoute = async ({ request, locals, url }) => {
const company = required(form.get('company')); const company = required(form.get('company'));
const email = required(form.get('email')); const email = required(form.get('email'));
const country = required(form.get('country')); const country = required(form.get('country'));
const department = required(form.get('department')) || 'general'; const department = required(form.get('department')) || 'info';
const message = required(form.get('message')); const message = required(form.get('message'));
if (!name || !email || !country || !message) { if (!name || !email || !country || !message) {