https://github.com/imhotepper/SpaApiMiddleware
This middleware will preserve the SPA navigation and functionality when the deep link of any page is sent via email or other communication tools. It will also preserve it when the page is refreshed in the browser.
Enable SPA calls to be served from wwwwroot and only /api calls to go through dotnet core controllers.
SPA served from wwwroot folder of a .Net Core 2 Api project.
> dotnet add package SpaApiMiddleware --version 1.0.1
In your .net core 2.0 Startup.cs class add :
using SpaApiMiddleware;and then in Configure method add:
app.UseSpaApiOnly();or with custom settings:
app.UseSpaApiOnly( indexHtmlPage:"index.html", apiPath:"api");Both apiPath and indexHtmlPage are optional parameters.
Dragos Stefanescu (Twitter/GitHub).
MIT License