Quote:
Originally Posted by RustyBrooks
So if you have a decoupled FE/BE and are serving your FE through something like cloudfront. Do you:
* proxy all your BE api calls through cloudfront also?
* "hard code" a domain name for the api, like your site is www.foo.com and your api is api.foo.com?
The latter is usually a ton easier to administer.
Even if you have a proxy you still have to have some kind of URL or other rule to where the proxy knows which calls go through to the API (not sure how fancy cloudfront can get with that). Unless you use two different cloudfronts and the front end just points to #2 for API calls.
We're still in development, so the react app is going straight to API Gateway. But I plan to put that behind cloudfront and then probably attach an api.x.com domain to it.
I'm using the create react app paradigm for environment files - so that each environment knows what API end point to point to (and whatever other env-specific settings we want to add). The downside is the app has to know what environment it's going to live in at build time (not boot time or run time). So there's no build once - then push around the artifact. Also I had to add env-cmd to handle more environments than just dev, stage, test, prod.
Code:
"env-cmd": "^8.0.2",
...
"build-dev": "node generate-build.js && env-cmd .env.development react-scripts build",
"build-stage": "node generate-build.js && env-cmd .env.stage react-scripts build",
"build-foo": "node generate-build.js && env-cmd .env.foo react-scripts build",
etc
Last edited by suzzer99; 03-20-2019 at 04:17 PM.