简体   繁体   中英

How to fetch variables.env variables in Angular and assign it to environment.ts or environment.prod.ts

I have build a docker which contains angular 4 application ,other services like superlogn,feedparser and database couchdb.

Presently in my root folder i have a varibales.env file where all the variables are declared and can be accessed in superlogin and feedparser services

But if we access the varaiables in angular application liks

dbusername=process.env.username

then the error we getting in angular production is process is undefined?

unable to access process.env in angular 4 application?

the Github link for the project is

https://github.com/janastu/iihs_couch_services/

Because Angular don't have access (and should not) to environment variables. This is very dangerous for your system.

If you want to expose your environments variables, which I don't recommend, you should create a Node application and make endpoints that return your environment variables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM