Node.js · Middle · Question 33 of 75
Why validate request input on the server even if the front end already validates it?
- 1Front-end validation doesn't work in all browsers
- ✓Correct answer: Anyone can send requests directly, bypassing the UI; the server is the only trusted boundary
- 3Validation on the server makes responses smaller
Explanation
Validate types, lengths and formats with a schema library (Zod, JSON Schema, Valibot) at the API boundary, and reject unknown fields.