Skip to content

Commit

Permalink
add cors to program
Browse files Browse the repository at this point in the history
  • Loading branch information
rolorogan committed Jul 25, 2024
1 parent 523129a commit 642b677
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
1 change: 0 additions & 1 deletion Wmca.Core/Wmca.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.3.0" />
<PackageReference Include="Umbraco.Cms.Core" Version="13.4.1" />
<PackageReference Include="Umbraco.Cms.Web.Common" Version="13.4.1" />
<PackageReference Include="Umbraco.Cms.Web.Website" Version="13.4.1" />
Expand Down
19 changes: 0 additions & 19 deletions Wmca.Web/Composers/CorsComposer.cs

This file was deleted.

13 changes: 13 additions & 0 deletions Wmca.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

builder.Services.AddCors(options =>
{
options.AddPolicy("MyAllowSpecificOrigins",
builder =>
{
builder.WithOrigins("https://dev-wmca.euwest01.umbraco.io", "https://www.wmca.org.uk", "http://localhost:1234/") // Replace with your allowed origins
.AllowAnyHeader()
.AllowAnyMethod();
});
});

builder.CreateUmbracoBuilder()
.AddBackOffice()
.AddWebsite()
Expand All @@ -17,6 +28,8 @@
app.UseHttpsRedirection();
#endif

app.UseCors("MyAllowSpecificOrigins");

app.UseUmbraco()
.WithMiddleware(u =>
{
Expand Down

0 comments on commit 642b677

Please sign in to comment.