I've created an ASP.NET Core 2.1 SPA app using the built-in React/Redux template which configures everything pretty nicely.
My app requires authentication and because it's a SPA app
, I want to keep my authentication options pretty simple so I configured only jwt
authentication and the MSAL
to handle jwt
tokens.
However, I'd like to have a simple static HTML page for public/non-authenticated users. So my question is how do I create this route for anonymous users and make sure they get redirected to it?
The project structure is shown below which is exactly what I got out of the box when VS created the React app for me:
And the only route I'm seeing in Startup.cs
along with SPA related configuration are:
app.UseStaticFiles();
app.UseSpaStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseReactDevelopmentServer(npmScript: "start");
}
});
So, in short, how do I go about creating a route for a static page I want to create for anonymous users and make sure my users get redirected to it if they're not coming in with a jwt
token?