refactor(api): loosen CORS to allow CF edge cache

This commit is contained in:
Collin Barrett 2025-05-31 12:16:51 -05:00 committed by Collin Barrett
parent 3865616802
commit ec1e006dc8

View file

@ -4,18 +4,11 @@ namespace FilterLists.Directory.Api;
internal static class CorsConfiguration
{
private const string ProductionClientOrigin = "https://filterlists.com";
private const string StagingClientOriginStart = "https://nice-water-05873140f";
private const string StagingClientOriginEnd = ".eastus2.5.azurestaticapps.net";
private const string LocalClientOrigin = "http://localhost:3000";
internal static readonly Action<CorsOptions> SetupAction = options => options.AddDefaultPolicy(policy =>
{
policy.SetIsOriginAllowed(origin =>
origin is ProductionClientOrigin or LocalClientOrigin ||
(origin.StartsWith(StagingClientOriginStart, StringComparison.InvariantCulture) &&
origin.EndsWith(StagingClientOriginEnd, StringComparison.InvariantCulture)))
.WithMethods("GET")
.AllowAnyHeader();
});
internal static readonly Action<CorsOptions> SetupAction = options =>
options.AddDefaultPolicy(policy =>
policy
.AllowAnyOrigin()
.WithMethods("GET")
.AllowAnyHeader()
);
}