diff --git a/examples/Demo/FluentUI.Explorers/Components/App.razor b/examples/Demo/FluentUI.Explorers/Components/App.razor index 800a933358..f3e95b84a2 100644 --- a/examples/Demo/FluentUI.Explorers/Components/App.razor +++ b/examples/Demo/FluentUI.Explorers/Components/App.razor @@ -5,6 +5,7 @@ + diff --git a/examples/Demo/FluentUI.Explorers/Components/Pages/EmojiExplorer.razor b/examples/Demo/FluentUI.Explorers/Components/Pages/EmojiExplorer.razor index c735681022..45d245693c 100644 --- a/examples/Demo/FluentUI.Explorers/Components/Pages/EmojiExplorer.razor +++ b/examples/Demo/FluentUI.Explorers/Components/Pages/EmojiExplorer.razor @@ -1,4 +1,5 @@ @page "/emoji-explorer" +@page "/emoji-explorer/embedded" @inherits ExplorerBase FluentUI Blazor - Emojis explorer diff --git a/examples/Demo/FluentUI.Explorers/Components/Pages/IconExplorer.razor b/examples/Demo/FluentUI.Explorers/Components/Pages/IconExplorer.razor index 163bc96917..1fdaa91b06 100644 --- a/examples/Demo/FluentUI.Explorers/Components/Pages/IconExplorer.razor +++ b/examples/Demo/FluentUI.Explorers/Components/Pages/IconExplorer.razor @@ -1,4 +1,5 @@ -@page "/icon-explorer" +@page "/icon-explorer" +@page "/icon-explorer/embedded" @inherits ExplorerBase FluentUI Blazor - Icons explorer diff --git a/examples/Demo/FluentUI.Explorers/Program.cs b/examples/Demo/FluentUI.Explorers/Program.cs index 97485eb8de..2e0d8a643e 100644 --- a/examples/Demo/FluentUI.Explorers/Program.cs +++ b/examples/Demo/FluentUI.Explorers/Program.cs @@ -20,10 +20,38 @@ if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error", createScopeForErrors: true); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } +// Override any default CSP headers with our custom policy +app.Use(async (context, next) => +{ + context.Response.OnStarting(() => + { + // Remove X-Frame-Options (it conflicts with CSP frame-ancestors) + context.Response.Headers.Remove("X-Frame-Options"); + + // Define allowed frame ancestors + string[] allowedFrameAncestors = + [ + "'self'", + "https://localhost:7026", + "https://localhost:7062", + "https://fluentui-blazor.net", + "https://www.fluentui-blazor.net", + "https://preview.fluentui-blazor.net", + "https://fluentui-explorer-v5.azurewebsites.net" + ]; + + // Set a single CSP header, replacing any that Blazor might have added + context.Response.Headers["Content-Security-Policy"] = + $"frame-ancestors {string.Join(" ", allowedFrameAncestors)};"; + + return Task.CompletedTask; + }); + await next(); +}); + app.UseHttpsRedirection(); app.UseAntiforgery(); diff --git a/examples/Demo/FluentUI.Explorers/ReadMe.md b/examples/Demo/FluentUI.Explorers/ReadMe.md index 2545df99e2..efe897b5e6 100644 --- a/examples/Demo/FluentUI.Explorers/ReadMe.md +++ b/examples/Demo/FluentUI.Explorers/ReadMe.md @@ -18,37 +18,18 @@ of the Fluent UI Blazor library. dotnet publish "FluentUI.Explorers.csproj" -c Release -o ./bin/Publish -f net9.0 ``` -## Update the Web.Config - -To allow an external site to embed your site in an iframe, -you need to add a [Content-Security-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors) item -the following to the generated ´web.config` file: - -```xml - - ... - - - - - - - - - ... - -``` - -## Deploy in Azure - -1. Compress the resulting folder into a ZIP file. +4. Compress the resulting folder into a ZIP file. ```bash Compress-Archive ./bin/Publish/* ./bin/FluentUI-Explorers.zip ``` -2. Open Azure Portal and navigate to the Web App **fluentui-explorer** (Slot `v5`) +## Deploy to Azure -3. Use the Development **Tools / Advanced Tools** to drop the Zip file in the root folder. +1. Open Azure Portal and navigate to the Web App **fluentui-explorer** (Slot `v5`) + Use the Development **Tools / Advanced Tools** to drop the Zip file + in the `site/wwwroot` folder. -4. Check the deployment: https://fluentui-explorer-v5.azurewebsites.net + https://fluentui-explorer-v5.scm.azurewebsites.net/DebugConsole + +2. Check the deployment: https://fluentui-explorer-v5.azurewebsites.net