Enable CORS for the API

This commit is contained in:
Ske 2019-07-16 14:20:25 +02:00
parent d416f39b36
commit e0a93ba608
2 changed files with 3 additions and 0 deletions

View File

@ -6,6 +6,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
</ItemGroup>

View File

@ -30,6 +30,7 @@ namespace PluralKit.API
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddCors();
services.AddMvc(opts => { })
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
.AddJsonOptions(opts => { opts.SerializerSettings.BuildSerializerSettings(); });
@ -60,6 +61,7 @@ namespace PluralKit.API
}
//app.UseHttpsRedirection();
app.UseCors(opts => opts.AllowAnyMethod().AllowAnyOrigin());
app.UseMiddleware<TokenAuthService>();
app.UseMvc();
}