Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force separate HTTP requests in "Server" mode #143

Open
ittennull opened this issue May 11, 2020 · 4 comments
Open

Force separate HTTP requests in "Server" mode #143

ittennull opened this issue May 11, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@ittennull
Copy link
Contributor

When Bolero works in "server" mode there is a websocket connection and whenever I define a service

type BookService =
    {
        signIn : string * string -> Async<option<string>>
    }
    interface IRemoteService with
        member this.BasePath = "/books"

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) throws InvalidOperationException("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

@OnurGumus
Copy link

@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.

@ittennull
Copy link
Contributor Author

@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

@OnurGumus
Copy link

It's the nature of web sockets. Even with blazor it's the same problem.

@Tarmil
Copy link
Member

Tarmil commented May 13, 2020

That being said, behind the scenes it uses SignalR, so maybe there's a way to force it to use long poll mode?

@Tarmil Tarmil added the enhancement New feature or request label Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants