Skip to content

Commit

Permalink
Added CORS to API Gateway
Browse files Browse the repository at this point in the history
Signed-off-by: Emil Balitzki <emil.balitzki@gmail.com>
  • Loading branch information
Corgam committed Jun 11, 2024
1 parent 89e46b0 commit df5cece
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions backend/api-gateway/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ public void ConfigureServices(IServiceCollection services)
services.AddControllers();
services.AddHttpClient();

// Add CORS services to allow all origins
services.AddCors(options =>
{
options.AddPolicy("AllowAll",
builder =>
{
builder.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
});
});

// Add Swagger services
services.AddSwaggerGen(c =>
{
Expand Down Expand Up @@ -48,6 +60,9 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
c.RoutePrefix = string.Empty; // Set Swagger UI at the root
});

// Enable CORS
app.UseCors("AllowAll");

app.UseRouting();

app.UseEndpoints(endpoints =>
Expand Down

0 comments on commit df5cece

Please sign in to comment.