From 4919ce8002a4f8660ec306f73c041c4ad273ddc0 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 8 Jan 2021 14:09:56 +0200 Subject: Implemented CORS in API (so Angular could accept requests from the API) --- src/DevHive.Web/Startup.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/DevHive.Web') diff --git a/src/DevHive.Web/Startup.cs b/src/DevHive.Web/Startup.cs index 42fc88a..96ab318 100644 --- a/src/DevHive.Web/Startup.cs +++ b/src/DevHive.Web/Startup.cs @@ -20,6 +20,8 @@ namespace DevHive.Web // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { + services.AddCors(); + services.AddControllers() .AddNewtonsoftJson(x => { @@ -36,6 +38,12 @@ namespace DevHive.Web // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { + app.UseCors(x => x + .AllowAnyMethod() + .AllowAnyHeader() + .SetIsOriginAllowed(origin => true) // allow any origin + .AllowCredentials()); // allow credentials + if (env.IsDevelopment()) { //app.UseDeveloperExceptionPage(); -- cgit v1.2.3