diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 1bc1c38..f9e854e 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -16,6 +16,10 @@ jobs: # Fail the action if any vulnerabilities are found fail-on-severity: moderate # Allow licenses (add/remove as needed for your project) - allow-licenses: MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, GPL-3.0 + allow-licenses: MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, GPL-3.0, MPL-1.1, MPL-2.0 + # Allow dependencies even if license detection fails + # System.Net.Http and System.Text.RegularExpressions are Microsoft packages with MIT licenses + # but GitHub may flag them as "OTHER" due to license metadata format + allow-dependencies-licenses: pkg:nuget/System.Net.Http, pkg:nuget/System.Text.RegularExpressions # Comment on PR with summary comment-summary-in-pr: always diff --git a/Albatross.csproj b/Albatross.csproj index ebb4fb2..ea610aa 100644 --- a/Albatross.csproj +++ b/Albatross.csproj @@ -58,10 +58,21 @@ + + + + + + + + diff --git a/Layout/MainLayout.razor b/Layout/MainLayout.razor index 9a7a0e4..c945227 100644 --- a/Layout/MainLayout.razor +++ b/Layout/MainLayout.razor @@ -1,5 +1,6 @@ @inherits LayoutComponentBase @using System.Reflection +@using Generated
@@ -57,11 +58,16 @@ protected override void OnInitialized() { Assembly assembly = typeof(Program).Assembly; - var version = assembly.GetName().Version; var title = assembly.GetCustomAttribute()?.Title ?? "Albatross"; - var buildDate = DateTime.Now.ToString("yyyy-MM-dd"); - @* BuildInfo = $"{title} v{version}"; *@ + // Extract date (YYYYMMDD) from timestamp (YYYYMMDD-HHMM) and use short build ID + var buildDate = BuildConstants.BuildTimestamp.Length >= 8 + ? BuildConstants.BuildTimestamp.Substring(0, 8) + : BuildConstants.BuildTimestamp; + var shortId = BuildConstants.BuildId.Length >= 8 + ? BuildConstants.BuildId.Substring(0, 8) + : BuildConstants.BuildId; + BuildInfo = $"{title}"; } } diff --git a/Program.cs b/Program.cs index c2eb9f5..fd2d872 100644 --- a/Program.cs +++ b/Program.cs @@ -7,14 +7,17 @@ builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); -builder.Services.AddScoped(sp => - new AbuseIPDBService( - sp.GetRequiredService() - ) -); - -// API access tokens are now hardcoded in the service for security purposes -// This makes them less discoverable than storing them in appsettings.json +ConfigureServices(builder.Services, builder.HostEnvironment.BaseAddress); await builder.Build().RunAsync(); + +// Extract service registration to static local function for prerendering support +static void ConfigureServices(IServiceCollection services, string baseAddress) +{ + services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseAddress) }); + services.AddScoped(sp => + new AbuseIPDBService( + sp.GetRequiredService() + ) + ); +} diff --git a/README.md b/README.md index ae60ccd..b3b95e8 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ A modern Blazor WebAssembly application that provides comprehensive IP address a - **Combined Data Sources**: Integrated AbuseIPDB and Cloudflare Radar API data for comprehensive IP analysis - **Secure Authentication**: Build-time generated HMAC authentication with timestamp validation for enhanced security - **CORS Protection**: Cloudflare Worker proxy handles CORS and protects API keys from client exposure +- **SEO-Optimized**: Static HTML prerendering for improved search engine indexing and web crawler accessibility - **Modern UI**: Clean, responsive Blazor WebAssembly interface with real-time JSON formatting - **Cross-Platform**: Runs on Windows, macOS, and Linux @@ -53,6 +54,41 @@ The project uses MSBuild targets for automated key generation and code injection - `Generated/build-manifest.json` - Build metadata and timestamps - `cloudflare-worker.js` - Final worker with injected authentication +## Prerendering + +Albatross uses **[BlazorWasmPreRendering.Build](https://github.com/jsakamoto/BlazorWasmPreRendering.Build)** to generate static HTML during the publish process, improving SEO and web crawler accessibility. + +### How It Works +- **Build-Time Rendering**: During `dotnet publish`, the app is rendered to static HTML +- **SEO Benefits**: Search engines can index content without executing JavaScript +- **Hidden Content**: Prerendered HTML is hidden (opacity: 0, z-index: -1) to prevent visual flash +- **Blazor Hydration**: The app seamlessly takes over after loading, providing full interactivity +- **Zero Runtime Overhead**: Prerendering happens at build time, not on the server + +### Implementation +For prerendering to work, service registration must be extracted into a static local function in `Program.cs`: +```csharp +static void ConfigureServices(IServiceCollection services, string baseAddress) +{ + services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseAddress) }); + services.AddScoped(/* ... */); +} +``` + +See the [BlazorWasmPreRendering.Build documentation](https://github.com/jsakamoto/BlazorWasmPreRendering.Build#services-registration) for more details. + +### Verification +To verify prerendering is working after deployment: +```bash +# Check for prerendering markers in the HTML +curl -s https://albatross.devnomadic.com | grep "PRERENDERING-BEGIN" + +# Or view page source in browser and search for: + +``` + +If prerendering is working, you'll see the full app structure in the HTML source, not just "Loading..." + ## Setup and Development ### Prerequisites diff --git a/wwwroot/sitemap.xml b/wwwroot/sitemap.xml index ae93054..e69de29 100644 --- a/wwwroot/sitemap.xml +++ b/wwwroot/sitemap.xml @@ -1,52 +0,0 @@ - - - - - - https://albatross.devnomadic.com/ - 2025-07-12 - weekly - 1.0 - - - - - https://albatross.devnomadic.com/ip-manifests/AWS.json - 2025-07-12 - daily - 0.8 - - - https://albatross.devnomadic.com/ip-manifests/Azure.json - 2025-07-12 - daily - 0.8 - - - https://albatross.devnomadic.com/ip-manifests/GCP.json - 2025-07-12 - daily - 0.8 - - - https://albatross.devnomadic.com/ip-manifests/Oracle.json - 2025-07-12 - daily - 0.8 - - - - - https://albatross.devnomadic.com/robots.txt - 2025-07-12 - monthly - 0.3 - - - - - -