Skip to content

Instantly share code, notes, and snippets.

@sonicparke
Last active May 7, 2017 17:40
Show Gist options
  • Save sonicparke/9e8369579dd98d3c688de4a450b51adc to your computer and use it in GitHub Desktop.
Save sonicparke/9e8369579dd98d3c688de4a450b51adc to your computer and use it in GitHub Desktop.
Setting Up the Angular CLI in Visual Studio for Mac
app.Use(async (context, next) =>
{
await next();
// If there’s no available file and the request doesn’t contain an extension, we’re probably trying to access a page.
// Rewrite request to use app root
if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value) && !context.Request.Path.Value.StartsWith(/api))
{
context.Request.Path =/index.html;
context.Response.StatusCode = 200; // Make sure we update the status code, otherwise it returns 404
await next();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment