Search code examples
asp.net-coreidentityblazor-webassemblyazure-static-web-app

Azure static web app Blazor WASM .Net Core API and Identity - Could not load settings from '_configuration


I want to publish my VS solution to Azure static web app, I'm using the template that has Blazor WASM, a .Net Core API and Authentication with Identity inside the API.

It works fine on my local machine but after being published as an Azure static web app, it runs but remains authorizing...

The error is:

Could not load settings from '_configuration'

This is the browser console:

enter image description here

Client - program.cs:

public class Program
{
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);
            builder.RootComponents.Add<App>("#app");

            builder.Services.AddHttpClient("x.ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress))
                .AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();

            // Supply HttpClient instances that include access tokens when making requests to the server project
            builder.Services.AddScoped(sp => sp.GetRequiredService<IHttpClientFactory>().CreateClient("x.ServerAPI"));

            builder.Services.AddApiAuthorization();

            await builder.Build().RunAsync();
        }
}

Need help making this work...


Solution

  • What was happening was the lack of a certificate in my case, I followed this answear and it worked: https://stackoverflow.com/a/66448397/12824729

    I dont know if it is possible to work without a certificate when we have to do authentications, tried making the Key type development but wont authenticate..