using Microsoft.AspNetCore.Components.WebAssembly.Http;

namespace JSMR.UI.Blazor.Services;

public sealed class IncludeRequestCredentialsMessageHandler : DelegatingHandler
{
    protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
    {
        // Tells browser fetch() to send cookies/auth headers on cross-origin requests
        request.SetBrowserRequestCredentials(BrowserRequestCredentials.Include);

        return base.SendAsync(request, cancellationToken);
    }
}