Commit ede7dece authored by Pieterjan Vanhoof's avatar Pieterjan Vanhoof Committed by Jeremy Bokobza

Add CORS service to allow Cross-Origin Requests (#27)

* Add CORS service to allow Cross-Origin Requests

* Use CORS policy, add ubuntu runtime
parent 2e591cb6
......@@ -28,6 +28,28 @@ namespace Breeze.Api
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add service and create Policy to allow Cross-Origin Requests
services.AddCors
(
options =>
{
options.AddPolicy
(
"CorsPolicy",
builder =>
{
var allowedDomains = new[]{"http://localhost","http://localhost:4200"};
builder
.WithOrigins(allowedDomains)
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();
}
);
});
// Add framework services.
services.AddMvc()
// add serializers for NBitcoin objects
......@@ -73,6 +95,8 @@ namespace Breeze.Api
loggerFactory.AddConsole(this.Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseCors("CorsPolicy");
app.UseMvc();
// Enable middleware to serve generated Swagger as a JSON endpoint.
......
......@@ -59,6 +59,7 @@
},
"runtimes": {
"win10-x64": {},
"win7-x64": {}
"win7-x64": {},
"ubuntu.16.04-x64": {}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment