mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Handle publicPath=/ in HMR. Fixes #1191.
This commit is contained in:
@@ -22,6 +22,7 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
|
|||||||
private readonly RequestDelegate _next;
|
private readonly RequestDelegate _next;
|
||||||
private readonly ConditionalProxyMiddlewareOptions _options;
|
private readonly ConditionalProxyMiddlewareOptions _options;
|
||||||
private readonly string _pathPrefix;
|
private readonly string _pathPrefix;
|
||||||
|
private readonly bool _pathPrefixIsRoot;
|
||||||
|
|
||||||
public ConditionalProxyMiddleware(
|
public ConditionalProxyMiddleware(
|
||||||
RequestDelegate next,
|
RequestDelegate next,
|
||||||
@@ -35,6 +36,7 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
|
|||||||
|
|
||||||
_next = next;
|
_next = next;
|
||||||
_pathPrefix = pathPrefix;
|
_pathPrefix = pathPrefix;
|
||||||
|
_pathPrefixIsRoot = string.Equals(_pathPrefix, "/", StringComparison.Ordinal);
|
||||||
_options = options;
|
_options = options;
|
||||||
_httpClient = new HttpClient(new HttpClientHandler());
|
_httpClient = new HttpClient(new HttpClientHandler());
|
||||||
_httpClient.Timeout = _options.RequestTimeout;
|
_httpClient.Timeout = _options.RequestTimeout;
|
||||||
@@ -42,7 +44,7 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
|
|||||||
|
|
||||||
public async Task Invoke(HttpContext context)
|
public async Task Invoke(HttpContext context)
|
||||||
{
|
{
|
||||||
if (context.Request.Path.StartsWithSegments(_pathPrefix))
|
if (context.Request.Path.StartsWithSegments(_pathPrefix) || _pathPrefixIsRoot)
|
||||||
{
|
{
|
||||||
var didProxyRequest = await PerformProxyRequest(context);
|
var didProxyRequest = await PerformProxyRequest(context);
|
||||||
if (didProxyRequest)
|
if (didProxyRequest)
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ namespace Microsoft.AspNetCore.Builder
|
|||||||
|
|
||||||
private static readonly JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings
|
private static readonly JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
// Note that the aspnet-webpack JS code specifically expects options to be serialized with
|
||||||
|
// PascalCase property names, so it's important to be explicit about this contract resolver
|
||||||
|
ContractResolver = new DefaultContractResolver(),
|
||||||
|
|
||||||
TypeNameHandling = TypeNameHandling.None
|
TypeNameHandling = TypeNameHandling.None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user