Search code examples
amazon-web-servicesamazon-ecsaws-fargateaws-application-load-balancer

What is the best way to connect a React Service to a Node Service on AWS ECS?


I have a cluster which contains two services: a React Service (Frontend) and a Node Service (Backend). I want to be able to connect the two to each other.

Currently I am doing it with an Application Load Balancer that has the front end running on port 443 and the backend running on a different port. The two services communicated with each other via API calls where the react will call the backend.

I am worried because with this setup the backend is exposed to the internet and I only want the backend to be accessed by the react service and nothing else.

How do I connect the two services in the most efficient and safe way possible?


Solution

  • A React app runs in the web browser, on the user's laptop/desktop PC. It does not run in the AWS environment. Your AWS React server simply serves up the static files to the visitor's web browsers.

    The app running in the user's web browsers needs to access your backend NodeJS sever via the Internet. So the NodeJS server has to be exposed to the Internet. The way you are doing it, by exposing them both via a single load balancer, is fine. From a network security perspective, there isn't much more you can do to secure this. You would need to use application security, such as JWT tokens validated by the backend, to provide more security.