Starts in:
2 DAYS
16 HRS
10 MIN
33 SEC
Starts in:
2 D
16 H
10 M
33 S
Open Closed

Angular Environment settings replaced by settings in server side appsettings.json #91


User avatar
0
wazbek created

Hi

Would it be possible to move the settings in the environment.ts file to the appsettings.json file in the HttpApi.Host project.

I am aware of how to add custom settings using the ISettingDefinitionContext etc. I am able to see those settings in the ConfigState:setting variable when running my angular apps. Is possible to replace the ConfigState:environment state with the settings from appsettings.json file and if so how would I go about doing this?

The reason I want to do this is to avoid having to build my angular apps for different environments and be able to control the settings in a file that I can modify at runtime. ie appsettings.json which will handle different settings for different environments using transforms.

Regards,

Warick


3 Answer(s)
  • User Avatar
    0
    Mehmet created

    Hi Warick,

    Can you explain a little more detail by giving an example?

  • User Avatar
    0
    wazbek created

    Hi Mehmet

    Yes no problem.

    I would like to remove these from the environment.ts file in my angular application.

    application: {
        name: 'Test'
      },
      oAuthConfig: {
        issuer: 'https://localhost:44373',
        clientId: 'Test_App',
        dummyClientSecret: '1q2w3e*',
        scope: 'Test',
        showDebugInformation: true,
        oidc: false,
        requireHttps: true
      },
      apis: {
        default: {
          url: 'https://localhost:44373'
        }
      },
      localization: {
        defaultResourceName: 'Test'
      }
    

    Add them to the appsettings.json in the HttpApi.Host project where I can control the values with transforms and have all application settings in one place.

    Then when my angular app starts up it loads those values from the ConfigState:settings rather than from the environment.ts file.

    I see the environment settings get passed into the CoreModule like this.

    CoreModule.forRoot({
          environment,
          requirements: {
            layouts: [...LAYOUTS]
          }
        }),
    

    Would it be possible to somehow get the settings from ConfigState and completely replace the environment settings before passing it to the CoreModule above?

  • User Avatar
    0
    Mehmet created

    apis property is required for app initialization.

    There is an action named SetEnvironment to replace environment on runtime. See the usage below:

    import { SetEnvironment } from '@abp/ng.core';
    //...
    this.store.dispatch(new SetEnvironment(new environment data here))
    
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06