diff --git a/OpenFTTH.APIGateway/Startup.cs b/OpenFTTH.APIGateway/Startup.cs index 37fb9c3..d002f9d 100644 --- a/OpenFTTH.APIGateway/Startup.cs +++ b/OpenFTTH.APIGateway/Startup.cs @@ -27,6 +27,8 @@ namespace OpenFTTH.APIGateway { public class Startup { + readonly string AllowedOrigins = "_myAllowSpecificOrigins"; + public Startup(IConfiguration configuration) { Configuration = configuration; @@ -68,6 +70,18 @@ public void ConfigureServices(IServiceCollection services) // Web stuff services.AddRazorPages(); + // CORS + services.AddCors(options => + { + options.AddPolicy(name: AllowedOrigins, + builder => + { + builder.AllowAnyOrigin(); + builder.AllowAnyMethod(); + builder.AllowAnyHeader(); + }); + }); + // Services used by the API gateways services.AddHostedService(); services.AddSingleton, ToposTypedEventObservable>(); @@ -75,7 +89,7 @@ public void ConfigureServices(IServiceCollection services) services.AddSingleton>(x => new QueryServiceClient( - x.GetRequiredService>>(), + x.GetRequiredService>>(), Configuration.GetSection("RemoteServices:RouteNetworkService").Value) ); @@ -105,6 +119,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseExceptionHandler("/Error"); } + app.UseCors(AllowedOrigins); + app.UseWebSockets(); app.UseGraphQLWebSockets("/graphql"); app.UseGraphQL("/graphql");