My application consists of an Angular front-end, an app layer, and a DB layer. The architecture can be seen in this image.
To serve the JS front-end bits to the client and proxy requests from the client to the app layer, I am using an nginx instance. If I deploy this nginx on a cloud VM with IP 18.1.1.1, I can point my browser to that IP, allowing the client to download the JS code. The JS code is configured to set the app server ip/fqdn to the same ip/fqdn as the one used for downloading the UI. The nginx proxy configuration then forwards all /api requests made by the JS code to a specific FQDN, which is currently set to 'http://yelb-appserver:4567/api' due to deploying these components as containers.
Now, I want to explore additional deployment methods. Specifically, I aim to host the Angular bits on an S3 bucket or another web server, and have the JS point directly to different endpoints such as an API GW, a separate EC2 instance, or a cloud load balancer. This means I cannot use the current configuration where the app server environment is based on window.location.host.
I am looking to create a dynamic and repeatable deployment workflow, possibly using cloud formation. I am exploring if it's possible to work with a single compiled JavaScript artifact that can parametrize the Angular code to point to the /api endpoint created at deployment time, instead of manually customizing and rebuilding the Angular app for each deployment.
Thank you.