You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But I cant because my clients must be created with IAntiforgeryHttpClientFactory so that IJSRuntime can work.
Would it work to use DelegatingHandler instead and that way any typed clients inherit that ability?
IE:
builder.Services.AddHttpClient("authorizedClient", client =>{client.BaseAddress=newUri(builder.HostEnvironment.BaseAddress);client.DefaultRequestHeaders.Accept.Add(newMediaTypeWithQualityHeaderValue("application/json"));}).AddTypedClient<IGitHubAPIClient>()// Will not pass antiforgery token!!! Must be created with IAntiforgeryHttpClientFactory!!! <---------.AddHttpMessageHandler<AuthorizedHandler>();builder.Services.AddTransient(sp =>sp.GetRequiredService<IHttpClientFactory>().CreateClient("default"));builder.Services.AddTransient<IAntiforgeryHttpClientFactory,AntiforgeryHttpClientFactory>();
The text was updated successfully, but these errors were encountered:
FYI You could also use a HTTP custom header instead of anti-forgery tokens to protect against this threat as well. Validate this on the backend. (forces preflight requests)
I want to add a typed client here https://github.com/damienbod/AspNetCoreExperiments/blob/main/BlazorBffAzureADWithApi/Client/Program.cs#L25
But I cant because my clients must be created with IAntiforgeryHttpClientFactory so that IJSRuntime can work.
Would it work to use DelegatingHandler instead and that way any typed clients inherit that ability?
IE:
The text was updated successfully, but these errors were encountered: