diff --git a/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddleware.cs b/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddleware.cs
index 3b5bb72..fa9be00 100644
--- a/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddleware.cs
+++ b/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddleware.cs
@@ -78,7 +78,9 @@ namespace Microsoft.AspNetCore.Builder
// Ideally, this would be relative to the application's PathBase (so it could work in virtual directories)
// but it's not clear that such information exists during application startup, as opposed to within the context
// of a request.
- var hmrEndpoint = "/__webpack_hmr";
+ var hmrEndpoint = !string.IsNullOrEmpty(options.HotModuleReplacementEndpoint)
+ ? options.HotModuleReplacementEndpoint
+ : "/__webpack_hmr"; // Matches webpack's built-in default
// Tell Node to start the server hosting webpack-dev-middleware
var devServerOptions = new
diff --git a/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddlewareOptions.cs b/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddlewareOptions.cs
index d41d97d..f94a8d2 100644
--- a/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddlewareOptions.cs
+++ b/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddlewareOptions.cs
@@ -13,6 +13,12 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
///
public bool HotModuleReplacement { get; set; }
+ ///
+ /// If set, overrides the URL that Webpack's client-side code will connect to when listening for updates.
+ /// This must be a root-relative URL similar to "/__webpack_hmr" (which is the default endpoint).
+ ///
+ public string HotModuleReplacementEndpoint { get; set; }
+
///
/// Overrides the internal port number that client-side HMR code will connect to.
///