My question is, I'm creating a react native application. I'm using mongoose, expressjs, nodejs, and mongodb. I am debating if to do the logic in front end or back end, where would it be ideal? I fell like back-end since it would be great in case I want to create a reactjs project in the future. What do you guys think? Example of what I want is display available times of the day where a user could purchase a service and each service has a time set. For example, if you purchase a service for a food and the time to create it takes 30 mins, then chef has that time unavailable.
CodePudding user response:
You must be aware that the frontend can always be manipulated by users. For example, properly pressing the "Order" button in your app may lead to a request
POST /Order?Food=IrishStew&Price=11
but a malicious can change that request to
POST /Order?Food=IrishStew&Price=1
and you would have to validate the price in the backend before accepting the order.
Summary: The frontend offers convenience for users, but every logic (for example, the price determination) that matters to the service company must be implemented in the backend.