0

I've got a client-server (with transpiled js and rpc calls to server) application with websharper, and it runs perfectly fine.

Now I need a single javascript file for another site (a WordPress app) and from this script, I'd like to access to everything public (non protected rpc) I made in my former client-server application.

The ideal would be to be able to use the websharper SPA template and "link" to the client-server project.

I've got two problems: - First, rpc signature are encoded with a hash which seems to be local to the app (no simple way to reproduct this hash outside it) - Second, apparently there is no way to actually link the generated dll from the client-server app into the new SPA template and use the exported rpc method signatures for the SPA.

Am I missing something, how to make this work ?

Regards,

1 Answers1

1

Referencing your client-server application from your SPA should work just fine; you just need to make sure that it points to the right URL by calling the following somewhere in your SPA:

WebSharper.Remoting.EndPoint <- "http://your-client-server-application's-url"
Tarmil
  • 11,177
  • 30
  • 35
  • Ok, that's a start. Now my problem is that I can't seem to trigger the CORS header in the website. I added `WebSharper.Web.Remoting.AddAllowedOrigin("http://localhost:51715")` the main `[]` but it doesn't trigger any `Access-Control-Allow-Origin` header. – François-David Collin Nov 14 '16 at 16:41
  • I just tried, added the AllowedOrigin as you just did, and I got the correct Access-Control-Allow-Origin in response and the RPC went through. `http://localhost:5‌​1715` is your SPA's URL, right? (also, how is your server app hosted: basic, Owin or Suave?) – Tarmil Nov 15 '16 at 10:42
  • It works only if I add `DisableCsrfProtection` I use the basic client-server container template (the one with asp.net) Now is there a way to reenable Csrf or is it by design ? – François-David Collin Nov 16 '16 at 13:12