Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/mono/wasm/host/DevServer/DevServerStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
using Microsoft.WebAssembly.AppHost;

namespace Microsoft.WebAssembly.AppHost.DevServer;
Expand Down Expand Up @@ -67,7 +68,6 @@ public static void Configure(IApplicationBuilder app, IOptions<DevServerOptions>
ServeUnknownFileTypes = true,
});

app.UseRouting();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call was a duplicate (see line 61)

app.UseWebSockets();

if (options.OnConsoleConnected is not null)
Expand Down Expand Up @@ -100,6 +100,14 @@ public static void Configure(IApplicationBuilder app, IOptions<DevServerOptions>
{
OnPrepareResponse = fileContext =>
{
// Avoid caching index.html during development.
// When hot reload is enabled, a middleware injects a hot reload script into the response HTML.
// We don't want the browser to bypass this injection by using a cached response that doesn't
// contain the injected script. In the future, if script injection is removed in favor of a
// different mechanism, we can delete this comment and the line below it.
// See also: https://github.com/dotnet/aspnetcore/issues/45213
fileContext.Context.Response.Headers[HeaderNames.CacheControl] = "no-store";

if (options.WebServerUseCrossOriginPolicy)
{
// Browser multi-threaded runtime requires cross-origin policy headers to enable SharedArrayBuffer.
Expand Down