Home > Net >  Connecting the frontend (HTML,CSS,JS) to the backend (Express)
Connecting the frontend (HTML,CSS,JS) to the backend (Express)

Time:03-30

So there's a few things I'm confused about with connecting a frontend to a backend part of a website, and I can't seem to find anything online about it.

  • Say you have a backend API, which if you had a endpoint which deletes a user, for if they want their account deleted, then what's stopping an attacker from just pinging the end point with a user ID and then it'll delete the user? I've heard that you can use like a password or something similar to stop fake attacks, but what's stopping somebody from just looking through the source code to find the code that is sent along with the request? Do you just use a user ID that would be hard to guess? But if so, why couldn't they just brute force user ID's?

  • Should the backend be run on the same domain as the frontend? Should you just have to use https://example.com:3000, or should you have to use the ip of the server and send data to https://000.000.000.00:3000?

Any help would be appreciated. I don't know that much about full stack development since I'm just now starting to learn, however what people say seems to be a really insecure way of doing it.

CodePudding user response:

1 - You can safe your backend with a JWT signed by User/Password to ensure that only signed users are calling to your API BACKEND, in your server you can use a service of DDOS and a Firewall to avoid this kind of attack.

2 - a Backend/Frontend of a website can be anywhere in web separated or not, in a home computer or in a cloud service, you must ensure that your Frontend can reach your backend wherever it is. Ofcourse you can do it in a single webserver, and its better for many reasons, such as process of deploy, performance of the website and safety.

and you can always learn more in documentations.

https://laravel.com/docs/9.x/csrf

CodePudding user response:

There are a csrf token stops unauthorized requests from passing .

a good example in Laravel Documentation

I hope it was useful !

  • Related