mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-25 02:57:31 +00:00
AddSpaStaticFiles/UseSpaStaticFiles APIs to clean up the React template (or other cases where SPA files are outside wwwroot)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.SpaServices
|
||||
@@ -26,11 +27,12 @@ namespace Microsoft.AspNetCore.SpaServices
|
||||
return next();
|
||||
});
|
||||
|
||||
// Serve it as file from wwwroot (by default), or any other configured file provider
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
FileProvider = options.DefaultPageFileProvider
|
||||
});
|
||||
// Serve it as a static file
|
||||
// Developers who need to host more than one SPA with distinct default pages can
|
||||
// override the file provider
|
||||
app.UseSpaStaticFilesInternal(
|
||||
overrideFileProvider: options.DefaultPageFileProvider,
|
||||
allowFallbackOnServingWebRootFiles: true);
|
||||
|
||||
// If the default file didn't get served as a static file (usually because it was not
|
||||
// present on disk), the SPA is definitely not going to work.
|
||||
|
||||
Reference in New Issue
Block a user