fhircast / sandbox

FHIRcast Sandbox
GNU Affero General Public License v3.0
12 stars 3 forks source link

Cors support for JavaScript clients #25

Closed mbellehumeur closed 6 years ago

mbellehumeur commented 6 years ago

To allows JavaScript on the browser to send subscription request and notification to the hub with Ajax, I believe we have to change the startup.cs file. This post describes the change: https://stackoverflow.com/questions/44379560/how-to-enable-cors-in-asp-net-core-webapi

In the ConfigureServices method of your startup.cs, add the CORS services. public void ConfigureServices(IServiceCollection services) { services.AddCors(); } Then in your Configure method of your startup.cs, add the following : public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { app.UseCors( options => options.WithOrigins("*").AllowAnyMethod() );

app.UseMvc();

}

mbellehumeur commented 6 years ago

Seems to work now,

thorstenconrad commented 5 years ago

Today the sandbox.js is still not able to communicate with the sandbox, because of CORS restrictions. I have made a (rudimental) patch for the Hub, hope it is useful.

sandbox_cors.txt