Skip to content

Spa Configuration Module

The SpaConfigurationModule provides a way for Suite AspNet Core Applications to serve the configuration required for a frontend to run.

The module will take care of serving an endpoint at api/SpaConfiguration/All which is where the client expects to find it.

In order to extend the output of the configuration endpoint, modules need to implement the ISpaConfigurationContributor interface. These will be discovered automatically by the SpaConfigurationModule and will be executed in order to compose the configuration endpoint.

Usage

In order to serve the configuration endpoint, the recommended way is to depend on the SpaConfigurationModule at your Backend For Frontend.

C#
builder.DependsOn<SpaConfigurationModule>();

This is all that's needed to serve current module's configuration (if any).

Custom Spa Configuration Contributor

If you'd like to extend the configuration endpoint with your own fields, you need to implement the ISpaConfigurationContributor interface.

C#
public class MyAppSpaConfigurationContributor : ISpaConfigurationContributor
{
    public Task<ContributorConfiguration> GetConfigurationAsync(CancellationToken ct)
    {
        return Task.FromResult(new ContributorConfiguration()
        {
            Key = "my-feature",
            Configuration = FetchMyAppConfigObjectFromSomewhere()
        });
    }
}

Note that you may use DI to inject services, IOptions and so on in order to build your configuration object.