*Audio Playback*

Content API:
 - Enabling CORS for access from Blazor app
Web Server:
 - Content API URL environment config
 - Web Audio API JS Interop layer in TypeScript
 - HttpClient configs
Web Client:
 - Audio Tack player controls
 - Audio Player example page
 - Audio Interop Service Layer
 - Named HttpClients
This commit is contained in:
daniel-c-harvey
2025-09-05 10:48:07 -04:00
parent a04bf06327
commit 7f78545a02
24 changed files with 1316 additions and 18 deletions
@@ -1,6 +1,5 @@
using DeepDrftContent.Constants;
using DeepDrftContent.FileDatabase.Models;
using DeepDrftContent.FileDatabase.Services;
using DeepDrftContent.Middleware;
using Microsoft.AspNetCore.Mvc;
+6
View File
@@ -0,0 +1,6 @@
namespace DeepDrftContent.Models;
public class CorsSettings
{
public string[] AllowedOrigins { get; set; } = [];
}
+19
View File
@@ -12,6 +12,24 @@ builder.Services.AddControllers();
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
// Add CORS policy using configured origins
var corsSettings = builder.Configuration.GetSection(nameof(CorsSettings)).Get<CorsSettings>();
if (corsSettings?.AllowedOrigins == null || corsSettings.AllowedOrigins.Length == 0)
{
throw new Exception("CorsSettings.AllowedOrigins configuration is required for CORS policy");
}
builder.Services.AddCors(options =>
{
options.AddPolicy("ContentApiPolicy", policy =>
{
policy.WithOrigins(corsSettings.AllowedOrigins)
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();
});
});
// Load API key configuration
builder.Configuration.AddJsonFile("environment/apikey.json", optional: false, reloadOnChange: true);
var apiKeySettings = builder.Configuration.GetSection(nameof(ApiKeySettings)).Get<ApiKeySettings>();
@@ -25,6 +43,7 @@ if (app.Environment.IsDevelopment())
app.MapOpenApi();
}
app.UseCors("ContentApiPolicy");
app.UseApiKeyAuthentication(apiKeySettings.ApiKey);
app.UseAuthorization();
@@ -4,5 +4,13 @@
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"CorsSettings": {
"AllowedOrigins": [
"http://localhost:5070",
"https://localhost:5071",
"http://localhost:3000",
"http://127.0.0.1:5070"
]
}
}
+4 -1
View File
@@ -5,5 +5,8 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"CorsSettings": {
"AllowedOrigins": []
}
}