Express backend & React frontend under the same domain

Viewed 134

I have a backend in Express.js deployed on Elastic Beanstalk and a frontend built with React.js deployed on Amplify and I would like to make HTTP (using axios) requests from the frontend to the backend via relative paths.

I'm quite new to AWS but I figured I could use Cloudfront to set the backend as a behaviour?

I have a domain (mydomain.com) for the frontend where the DNS are pointing to Amplify cloudfront (which I think I can't access...) and Elastic Beanstalk has its own aws domain (http://app-name.region.elasticbeanstalk.com/).

The frontend seems to be working fine as if I go to mydomain.com I can see it. Also the backend seems to be working as if I go to http://app-name.region.elasticbeanstalk.com/api/user it would return the expected json data.

The idea would be though that mydomain.com serves my React application which internally would make calls to, for example, mydomain.com/api/user where my express backend would serve the user.

I got lost in the docs and on the internet didn't really find anything.

Is using Cloudfront the right approach? If so, how do I connect Amplify and Elastic Beanstalk?

Any suggestion would be very appreciated!

0 Answers
Related