Reputation: 767
I'm quite new to AWS and web development so please bear me if my questions look silly.
My question is, how can I access (like make ajax call) to Express service inside React app in production enviroment? Just append any ajax call with the service address?
The s3 bucket React app is in was created by AWS codestar, does that mean the React and Express are on the same machine? I mean if they are on same machine the ajax call will be faster, right?
Another option is, since Codestar instantiated an EC2, I can deploy the React into the EC2. So that Express on EC2 serves all API requests but for static files and index.html Express directly returns the deployed React assets.
Anyone knows which solution is better?
Upvotes: 2
Views: 1286
Reputation: 1859
Well, the best solution is the one that fits better your needs. For example, if you would need server side rendering, it would be better to add your React application to the EC2 that is currently holding your express app; aside from that, I would continue using S3 bucket for your compiled React application. If your concern is about performance/latency, you can use AWS Cloudfront to improve those timings.
To access your Express app, you call your application's IP (under AWS Console > EC2 > your instance > IPv4 Public IP or Public DNS (IPv4) as your host in the ajax call.
Just to clarify, your EC2 and S3 bucket are in different machines.
Upvotes: 4