Skip to content

Commit 8f75a86

Browse files
TD-6384: CORS Policy Changes for Moodle Heart beat
1 parent 9c300a7 commit 8f75a86

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

LearningHub.Nhs.WebUI/Program.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@
3535
builder.Logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
3636
builder.Host.UseNLog();
3737

38+
string corsMoodleUrl = builder.Configuration.GetValue<string>("MoodleAPIConfig:BaseUrl");
39+
40+
builder.Services.AddCors(options =>
41+
{
42+
options.AddPolicy("MoodleCORS", builder =>
43+
{
44+
builder.WithOrigins(corsMoodleUrl)
45+
.AllowAnyHeader()
46+
.AllowAnyMethod()
47+
.AllowCredentials();
48+
});
49+
});
50+
3851
builder.Services.AddHostedService<TimedHostedService>();
3952
builder.Services.ConfigureServices(builder.Configuration, builder.Environment);
4053

@@ -78,6 +91,8 @@
7891
app.UseHttpsRedirection();
7992
}
8093

94+
app.UseCors("MoodleCORS");
95+
8196
app.UseRouting();
8297

8398
app.UseAuthentication();

0 commit comments

Comments
 (0)