Environment

Every application needs some environment variables. In Angular world, this is usually managed by environment.ts, environment.prod.ts and so on. It is the same for ABP as well.

Current Environment configuration holds sub config classes as follows:

  1. export interface Environment {
  2. apis: Apis;
  3. application: Application;
  4. oAuthConfig: AuthConfig;
  5. production: boolean;
  6. remoteEnv?: RemoteEnv;
  7. }

Apis

  1. export interface Apis {
  2. [key: string]: ApiConfig;
  3. default: ApiConfig;
  4. }
  5. export interface ApiConfig {
  6. [key: string]: string;
  7. rootNamespace?: string;
  8. url: string;
  9. }

Api config has to have a default config and it may have some additional ones for different modules. I.e. you may want to connect to different Apis for different modules.

Take a look at following example

  1. {
  2. // ...
  3. "apis": {
  4. "default": {
  5. "url": "https://localhost:8080",
  6. },
  7. "AbpIdentity": {
  8. "url": "https://localhost:9090",
  9. }
  10. },
  11. // ...
  12. }

When an api from AbpIdentity is called, the request will be sent to "https://localhost:9090". Everything else will be sent to "https://localhost:8080"

  • rootNamespace (new) : Root namespace of the related API. e.g. Acme.BookStore

Application

  1. export interface Application {
  2. name: string;
  3. baseUrl?: string;
  4. logoUrl?: string;
  5. }
  • name: Name of the backend Application. It is also used by logo.component if logoUrl is not provided.
  • logoUrl: Url of the application logo. It is used by logo.component
  • baseUrl: For detailed information

AuthConfig

For authentication, we use angular-oauth2-oidc. Please check their docs out

RemoteEnvironment

Some applications need to integrate an existing config into the environment used throughout the application. Abp Framework supports this out of box.

To integrate an existing config json into the environment, you need to set remoteEnv

  1. export type customMergeFn = (
  2. localEnv: Partial<Config.Environment>,
  3. remoteEnv: any,
  4. ) => Config.Environment;
  5. export interface RemoteEnv {
  6. url: string;
  7. mergeStrategy: 'deepmerge' | 'overwrite' | customMergeFn;
  8. method?: string;
  9. headers?: ABP.Dictionary<string>;
  10. }
  • url *: Required. The url to be used to retrieve environment config
  • mergeStrategy *: Required. Defines how the local and the remote environment json will be merged
    • deepmerge: Both local and remote environment json will be merged recursively. If both configs have same nested path, the remote environment will be prioritized.
    • overwrite: Remote environment will be used and local environment will be ignored.
    • customMergeFn: You can also provide your own merge function as shown in the example. It will take two parameters, localEnv: Partial<Config.Environment> and remoteEnv and it needs to return a Config.Environment object.
  • method: HTTP method to be used when retrieving environment config. Default: GET
  • headers: If extra headers are needed for the request, it can be set through this field.

What’s Next?