aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-01-08 14:09:56 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-01-08 14:09:56 +0200
commit4919ce8002a4f8660ec306f73c041c4ad273ddc0 (patch)
tree66a204d1e278933e7ae07ab72df3eef310794604 /src
parent6770bf97d05aa116fda03ed45a828505ee9ba235 (diff)
downloadDevHive-4919ce8002a4f8660ec306f73c041c4ad273ddc0.tar
DevHive-4919ce8002a4f8660ec306f73c041c4ad273ddc0.tar.gz
DevHive-4919ce8002a4f8660ec306f73c041c4ad273ddc0.zip
Implemented CORS in API (so Angular could accept requests from the API)
Diffstat (limited to 'src')
-rw-r--r--src/DevHive.Web/Startup.cs8
1 files changed, 8 insertions, 0 deletions
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();