Zaid-Ajaj / Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
https://zaid-ajaj.github.io/Fable.Remoting/
MIT License
273 stars 55 forks source link

Remove powerpack in favor of simple XMLHttpRequest #86

Closed Zaid-Ajaj closed 6 years ago

Zaid-Ajaj commented 6 years ago

Fixes #80 and simplifies the overall proxy implementation

Breaking changes:

CustomHeaders in type RemoteBuilderOptions are now of type (string * string) list

Response in ProxyRequestException is simplified to:

type HttpResponse = {
    StatusCode: int 
    ResponseBody: string
}

instead of using the full Response type from PowerPack

Notes

@Elonon I am not sure what the equivalent is to Crendentials: Same-origin when I am using XMLHttpRequest, any ideas?

Elonon commented 6 years ago

XMLHttpRequest will send httpOnly cookies by default as long as it is the same origin. For other domains, you must set withCredentials = true.

See here for more info.

Zaid-Ajaj commented 6 years ago

@Elonon I have read that but I wasn't sure if it is needed since I am explicitly adding document.cookie to the request headers by hand, I also looked into the handling of credentials in github/fetch and it seems to switch withCredentials to true only when request.credentials is "include" which I was not using in previous release

Elonon commented 6 years ago

httpOnly cookies still aren't available in document.cookie, but you are correct that to match your previous set up, you don't need to set withCredentials to true. I mentioned it because maybe you want to provide an option if a user needs it. You should not set it to true by default at any rate. It might be a good idea to add an integration test that ensures that httpOnly cookies are round-tripped. I may be able to look into that next week if you like.

Zaid-Ajaj commented 6 years ago

@Elonon That would be awesome! Thanks a lot :smile: send a PR anytime you like and I will review