How do you access front-end environment variables when using the Yeoman angular -fullstack generator?

I am using the Yeoman angular-fullstack generator .

I want to access some environment variables in the front-end controller ( main.controller.js). The only way I know how to set environment variables is this:

server / config / environment / local.env.js

'use strict';

// Use local.env.js for environment variables that grunt will set when the server starts locally.
// Use for your api keys, secrets, etc. This file should not be tracked by git.
//
// You will need to set these on the server you deploy to.

module.exports = {
  DOMAIN: 'hidden',
  SESSION_SECRET: "hidden",
  // Control debug level for modules using visionmedia/debug
  DEBUG: 'hidden',
  CALENDAR_ID: 'hidden',
  API_KEY: 'hidden'
};

However, from what I understand, this only makes it available on the server, but I want it on the front side. The following do not work in my front controller: ENV.API_KEYand process.env.API_KEY.

What should I do?

+1
source share
1

, , () , , , , , -. .

-1

Source: https://habr.com/ru/post/1623680/


All Articles