Skip to content

Commit

Permalink
RC 1.2.1 - Caching & CORS (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobpretorius authored May 14, 2024
1 parent 11c674c commit 3bdb220
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions UniversalNFT.dev.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
builder.Services.AddResponseCaching();

// Swagger
builder.Services.AddEndpointsApiExplorer();
Expand Down Expand Up @@ -48,18 +47,10 @@
builder.Services.Configure<IpRateLimitOptions>(builder.Configuration.GetSection("IpRateLimiting"));
builder.Services.AddInMemoryRateLimiting();
builder.Services.AddSingleton<IRateLimitConfiguration, RateLimitConfiguration>();
builder.Services.AddResponseCaching();

var app = builder.Build();

// We cache
app.Use(async (context, next) =>
{
context.Request.Headers.Remove("Pragma");
context.Request.Headers.Remove("Cache-Control");
await next();
});
app.UseResponseCaching();

app.UseIpRateLimiting();

app.UseSwagger();
Expand All @@ -80,4 +71,13 @@
.AllowAnyMethod()
.AllowAnyHeader());

// We cache
app.Use(async (context, next) =>
{
context.Request.Headers.Remove("Pragma");
context.Request.Headers.Remove("Cache-Control");
await next();
});
app.UseResponseCaching();

app.Run();

0 comments on commit 3bdb220

Please sign in to comment.