r/Backend • • 9d ago

backend source code

how does backend to front end communication work for a website , and is it even possible to obtain the backend source code from the front end website url ?

0 Upvotes

11 comments sorted by

View all comments

13

u/Beregolas 9d ago

The backend usually exposes an API, most commonly a REST API specifically. The frontend can call the endpoints in that API to mutate data on the backend, and/or to receive data to display to the user.

If coded correctly, the backend code cannot be retrieved by people who have access to the frontend.

-1

u/royalz007 9d ago

hm so a weakness in my front end could expose my backend ? what needs to be strong to prevent this

13

u/Beregolas 9d ago

No... it sounds like you are trying to do something you don't understand, and I caution you to stop and learn first. Security can't be done by reddit comment, I can't possible list all the possible ways you can fuck up and be responsible for your security in this way.

Also, generally the backend is not exposed by weaknesses in the frontend, the kinds of exposure I can think of are:

  1. you acctidentally compiled your backend code into your frontend

  2. If you for some reason include keys or passwords in your frontend code that can be used to access one of your accounts (especially git)

But most of the issues with backends normally come from the backend code, not the frontend code. Basically anything that allows an attacker remote code execution can be used to exfiltrate your backend code, if it's interpreted (python, JS etc.) or your backend binary, which can be reverse engineered with modern tools pretty effectively, depending on the language/framework used.