Open ittennull opened 4 years ago
@ittennull better you should use json web tokens. Here's an example that works for both WASM and Non Wasm scenario: https://github.com/OnurGumus/FBlazorShop
I basically create a JWT and store it to cookie.
IMHO, The way of F# is stay away all this magical mambo jambo created by microsoft for authentication etc. because we simply don't need them.
@OnurGumus thanks, I considered using JWT but cookie and built-in auth middleware seemed easier because I didn't need to add almost anything to the client, only server side. I will poke around a bit and maybe switch to JWT too.
Anyway it's still an issue that the standard bolero template doesn't work in server mode, not nice to newcomers
It's the nature of web sockets. Even with blazor it's the same problem.
That being said, behind the scenes it uses SignalR, so maybe there's a way to force it to use long poll mode?
When Bolero works in "server" mode there is a websocket connection and whenever I define a service
the request is sent via this websocket. In "wasm" mode the same request is sent via regular HTTP request. How to force it to always use regular HTTP requests? I know I can create a HttpClient and do it myself but I'd like to use record types as in the example. The problem is that in "server" mode you can't set cookie in signIn:
httpContext.SignInAsync(principal)
throwsInvalidOperationException("Headers are read-only, response has already started.")
because it tries to modify headers of an ongoing response. Even the standard Bolero template doesn't work in "wasm" mode