Angular cli template published version returns index.html when asked for .css/.js #84

Closed
opened 2025-08-09 17:14:56 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @ShaneCourtrille on 4/23/2018

I'm using the Angular CLI template but I've adjusted it to allow us to also server an existing MVC application by using this in my Startup.cs

app.Map(new Microsoft.AspNetCore.Http.PathString("/administration"), mapConfig => {
	mapConfig.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.UseAngularCliServer(npmScript: "start");
			spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");
		}
	});
});

I've done a dotnet publish and I'm trying to get the site working locally before I push it out. I set my ASPNETCORE_ENVIRONMENT to Production and I use dotnet EDM.dll to start my site. If I visit the MVC side of things then no issues but if I go to the Angular side it's not working because when the bundle.js or bundle.css are requested the result I'm receiving is the Angular sites index.html.

I've verified that in my ClientApp/dist the js and css files are correct so I'm assuming an incorrect configuration somewhere but could use a pointer as to where it could be.

*Originally created by @ShaneCourtrille on 4/23/2018* I'm using the Angular CLI template but I've adjusted it to allow us to also server an existing MVC application by using this in my Startup.cs ``` app.Map(new Microsoft.AspNetCore.Http.PathString("/administration"), mapConfig => { mapConfig.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.UseAngularCliServer(npmScript: "start"); spa.UseProxyToSpaDevelopmentServer("http://localhost:4200"); } }); }); ``` I've done a dotnet publish and I'm trying to get the site working locally before I push it out. I set my ASPNETCORE_ENVIRONMENT to Production and I use dotnet EDM.dll to start my site. If I visit the MVC side of things then no issues but if I go to the Angular side it's not working because when the bundle.js or bundle.css are requested the result I'm receiving is the Angular sites index.html. I've verified that in my ClientApp/dist the js and css files are correct so I'm assuming an incorrect configuration somewhere but could use a pointer as to where it could be.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#84
No description provided.