You are correct any code you have on the front end can copied and used elsewhere. So it can be useful to keep important proprietary algorithms, etc. in backend code.
You can obfuscate code which could help, but at the end of the day, if somebody is willing to put in the effort they'll be able to figure it out eventually.
However, I think in your case you have a more important reason not addressed to run the code in the back end, to enforce business and system invariants.
In the case you presented above it would be tax calculation. If you don't at the very least reevaluate the taxes on the backend then somebody can decide the pay whatever amount they want for taxes (which I'm assuming wouldn't be great).
Same thing for product prices, etc. You should never assume any data you receive from the user is valid and instead should always validate.
Maybe that's already clear, but thought I'd point it out just in case.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey Menning,
You are correct any code you have on the front end can copied and used elsewhere. So it can be useful to keep important proprietary algorithms, etc. in backend code.
You can obfuscate code which could help, but at the end of the day, if somebody is willing to put in the effort they'll be able to figure it out eventually.
However, I think in your case you have a more important reason not addressed to run the code in the back end, to enforce business and system invariants.
In the case you presented above it would be tax calculation. If you don't at the very least reevaluate the taxes on the backend then somebody can decide the pay whatever amount they want for taxes (which I'm assuming wouldn't be great).
Same thing for product prices, etc. You should never assume any data you receive from the user is valid and instead should always validate.
Maybe that's already clear, but thought I'd point it out just in case.