using Microsoft.AspNetCore.Components.WebAssembly.Http;

namespace planli.frontend.Services;

/// <summary>
/// Adds <c>credentials: 'include'</c> to every outgoing fetch so the browser
/// automatically attaches the HttpOnly auth cookies.
/// </summary>
public class CookieHandler : DelegatingHandler
{
    protected override Task<HttpResponseMessage> SendAsync(
        HttpRequestMessage request, CancellationToken ct)
    {
        request.SetBrowserRequestCredentials(BrowserRequestCredentials.Include);
        return base.SendAsync(request, ct);
    }
}
