I'm trying to grab an Environmental Variable from inside of a Docker Container using Angular Universal. I need to be able to pass this to my browser to be used by the app.component at run time.
The ENV is set by my Docker file and is present inside of the container when it runs
VARS_TEST_TOKEN='HELLO_WORLD'
On the server side I was pulling in the Process module from Node.js and grabbing the variable inside the server to use as Inject Token. When I run this I do see the variable displayed on the server side.
export const VARS_TEST_TOKEN = new InjectionToken<string>('');
export const varsTestFactory = process.env['VARS_TEST_TOKEN']
Inside of my Module I set it up like a provider to be injected into my component
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserTransferStateModule
],
providers: [{
provide: VARS_TEST_TOKEN,
useValue: varsTestFactory,
},]
Finally my app.component looks like this
constructor(
@Inject(DD_VARS_TEST_TOKEN) private _token: string,
){
console.log("IS THIS THING ON ", _token);
}
Basically what comes up in the browser is this.
IS THIS THING ON: undefined
Do I need to do this using the BrowserTransferStateModule? I wasn't sure how it worked.