From 5674adbd5ef5ee1d453ae777eddbee8d3a61039b Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 23 May 2023 13:16:37 +0200 Subject: [PATCH] Added CORS for localhost --- Tranga-API/Program.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Tranga-API/Program.cs b/Tranga-API/Program.cs index 9ee8650..3c4c4c6 100644 --- a/Tranga-API/Program.cs +++ b/Tranga-API/Program.cs @@ -28,13 +28,24 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); builder.Services.AddControllers().AddNewtonsoftJson(); + +string corsHeader = "Tranga"; +builder.Services.AddCors(options => +{ + options.AddPolicy(name: corsHeader, + policy => + { + policy.WithOrigins("http://localhost", "http://127.0.0.1", "http://localhost:63342"); + }); +}); + var app = builder.Build(); app.UseSwagger(); app.UseSwaggerUI(); app.UseSwagger(); app.UseSwaggerUI(); -app.MapGet("/GetAvailableControllers", () => taskManager.GetAvailableConnectors()); +app.UseCors(corsHeader); app.MapGet("/GetKnownPublications", () => taskManager.GetAllPublications());