Configure and Deploy dot Net Core API with Angular 8 front end Together | Host on same domain
public void
Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.Use(async
(context, next) =>
{
await next();
if(context.Response.StatusCode==404 && !System.IO.Path.HasExtension(context.Request.Path.Value))
{
context.Request.Path = "/index.html";
await next();
}
});
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseCors(builder =>
builder.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod()
);
app.UseAuthentication();
app.UseMvc();
}
No comments