Data API and Blazor WASM

Hi everyone!

Lately I’ve been trying to pick up MongoDB and see what I can do with it. Since the resources I’ve been searching for are either hard to find , or most likely, I’m not searching for the right terms, I’ve decided to give the forums ago and see what I can do here. So, new guy here, nice to meet you all!

So the thing I’m working on is trying to at least read data from MongoDB and display in a browser through a Blazor WASM front-end. It’s an interesting journey so far. One of the more exciting things I’m looking at, is being able to use the Data API feature and retire the ASP.Net Core back-end. This hasn’t been as easy as I’d hope however.

  • Connecting directly through the driver doesn’t seem to work at all. Now I’ve already expected that not to work, since you don’t want to pass your driver together with your front-end. I did follow something on YouTube with two developers demonstrating that exactly this is possible though, but my connection string was refused, where it did work when I tried it through back-end.

  • I’ve tried to use a combination of Realm and Atlas Device Sync which we’ve got working perfectly fine in Angular at work, but that doesn’t appear to be supported in Blazor.
    In that case I’d make do with Data API and pushing stuff via good old SignalR.

  • So, I get my examples for Postman, where the Data API works fine and set out to configure my HttpClient to do exactly the same calls. Still no luck. It is giving me CORS errors, which I can solve rather easily from my back-end, but the point of this exercise was to retire it. As I’ve read before on this forum, directly connecting with the Data API from the browser is not supported.

There’s probably a better way to go at this though. Does anyone else have any idea what else I could try?
Thanks in advance!