Skip to content

Commit 734935a

Browse files
Merge pull request #272 from TechnologyEnhancedLearning/Develop/Fixes/CORS-Policy-Update-for-moodle
Develop/fixes/cors policy update for moodle
2 parents 01f055c + b772521 commit 734935a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Auth/LearningHub.Nhs.Auth/Program.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
builder.Host.UseNLog();
2525

2626
string corsOriginUrl = builder.Configuration.GetValue<string>("LearningHubAuthConfig:AuthClients:learninghubopenapi:BaseUrl");
27+
string corsMoodleUrl = builder.Configuration.GetValue<string>("MoodleAPIConfig:BaseUrl");
2728

2829
builder.Services.AddCors(options =>
2930
{
@@ -34,6 +35,17 @@
3435
.AllowAnyHeader());
3536
});
3637

38+
builder.Services.AddCors(options =>
39+
{
40+
options.AddPolicy("MoodleCORS", builder =>
41+
{
42+
builder.WithOrigins(corsMoodleUrl)
43+
.AllowAnyHeader()
44+
.AllowAnyMethod()
45+
.AllowCredentials();
46+
});
47+
});
48+
3749
builder.Services.ConfigureServices(builder.Configuration, builder.Environment);
3850

3951
GlobalDiagnosticsContext.Set("connectionString", builder.Configuration.GetSection("ASPNETCORE_ConnectionStrings")["NLogDb"]);
@@ -72,6 +84,8 @@
7284

7385
app.UseCors("CorsPolicy");
7486

87+
app.UseCors("MoodleCORS");
88+
7589
app.UseCookiePolicy();
7690

7791
app.UseHttpsRedirection();

0 commit comments

Comments
 (0)