-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
This library isn't working on Blazor WASM because of this 'x-query-timeout' header usage.
All HTTPClient calls get exceptions like:
Access to fetch at 'https://db.fauna.com/' from origin 'https://.....' has been blocked by CORS policy: Request header field x-query-timeout is not allowed by Access-Control-Allow-Headers in preflight response.
Until this issue is solved on the FaunaDB cloud side you can use the following workaround:
Remove the 'x-query-timeout' header in the request.
public class MessageHandler : DelegatingHandler
{
public MessageHandler(HttpClientHandler httpClientHandler) :
base(httpClientHandler)
{ }
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
// Dont use header 'X-Query-Timeout' for CORS policy
request.Headers.Remove("X-Query-Timeout");
return base.SendAsync(request, cancellationToken);
}
}
public async void ContactFaunaDb()
{
var httpClient = new HttpClient(new MessageHandler(new HttpClientHandler()));
var faunaDb = new FaunaClient(endpoint: Endpoint, secret: Secret, httpClient: httpClient);
var rawIndexValues = await faunaDb.Query(Paginate(Match(Index("some_index"))));
/// etc....
}
evbruno and timonmasberg
Metadata
Metadata
Assignees
Labels
No labels