I’m working on an Angular application where I need to access environment variables within a standalone component. The main challenge is that these environment variables are only available at runtime, injected into the container from AWS Secrets Manager during the containerisation process. I initially tried using Angular’s Transfer State, but it requires the environment variables to be present at build time, which isn’t feasible in this scenario.
Here’s the detailed workflow:
Build Process:
- Containerisation: Using Docker to create the container image.
- Deploy to AWS: Referenced the image to run a container in ECS
- Secrets Management: Environment variables are stored in AWS Secrets Manager and injected into the container.
My question is: How can I dynamically access these environment variables in my Angular standalone component at runtime? Because it is currently returning undefined
.
So far, I’ve tried using TransferState: But it requires environment variables at build time. I also don’t see anything in Angular’s documentation about environment variables with SSR.