I was trying to use UseProxyToSpaDevelopmentServer option from inside of local service fabric cluster and I got no results. I literally didn't get any requests from server, when I was trying to access SPA application by route http://localhost:9000/UI/
. I'm using asp.net core 2.1 angular template. I use Razor to create an initial Angular page.
My Startup class looks like:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
}
app.UseStaticFiles();
app.UseSpaStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
app.UseSpa(spa =>
{
// To learn more about options for serving an Angular SPA from ASP.NET Core,
// see https://go.microsoft.com/fwlink/?linkid=864501
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseProxyToSpaDevelopmentServer("http://localhost:4200/");
}
});
}
I'm running application in development mode for sure.
I tried to get any request by launching basic node js server as well as angular app with ng serve
command, but as I said got no results.
I actually figured it out. The problem is app.UseSpa
is coming after app.UseMvc
. Since my razor page has been called Index.cshtml, MVC is taking over Spa requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With