Skip to content
This repository was archived by the owner on May 1, 2018. It is now read-only.

Commit 51ced7d

Browse files
committed
[config]: Add CORS
1 parent afe7525 commit 51ced7d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

WebApiServer/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static IWebHost BuildWebHost(string[] args) =>
6161
WebHost.CreateDefaultBuilder(args)
6262
.UseStartup<Startup>()
6363
#if !DEBUG
64-
.UseUrls("http://0.0.0.0:80")
64+
.UseUrls("http://0.0.0.0:5001")
6565
#endif
6666
.Build();
6767
}

WebApiServer/Startup.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ public Startup(IConfiguration configuration)
4747
/// </param>
4848
public void ConfigureServices(IServiceCollection services)
4949
{
50+
services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
51+
{
52+
builder.AllowAnyOrigin()
53+
.AllowAnyMethod()
54+
.AllowAnyHeader();
55+
}));
5056
var connection = Configuration.GetConnectionString("DefaultConnection");
5157
services.AddDbContext<Models.ApiContext>(options => options.UseSqlServer(connection));
5258
services.AddMvc();
@@ -64,6 +70,7 @@ public void ConfigureServices(IServiceCollection services)
6470
// ReSharper disable once UnusedMember.Global
6571
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
6672
{
73+
app.UseCors("MyPolicy");
6774
app.Use(async (context, next) => {
6875
await next();
6976

0 commit comments

Comments
 (0)