Cos'è CORS e Come Risolvere gli Errori CORS
Il frontend gira su http://localhost:5173, l’API su http://localhost:4000, e la fetch che funzionava perfettamente in Postman fallisce nel browser con un muro di testo rosso: Access to fetch at 'http://localhost:4000/api/users' from origin 'http://localhost:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Il server potrebbe aver gestito la richiesta e restituito un 200. Il browser ha semplicemente rifiutato di consegnare la risposta al tuo JavaScript. ...