I'm attempting to configure ASP.NET Core to disallow serving .map files in certain situations. I have attempted to remove it from the known filetypes, but that doesn't seem to prevent it from actually serving the file. This is what I have now:
app.UseSpa(spa =>
{
spa.Options.SourcePath = "Client";
if (env.IsDevelopment())
{
var customPort = 60001;
spa.UseProxyToSpaDevelopmentServer($"http://localhost:{customPort}");
spa.UseReactDevelopmentServer("start");
}
});
var contentTypeProvider = new FileExtensionContentTypeProvider();
contentTypeProvider.Mappings.Remove(".map");
app.UseSpaStaticFiles(new StaticFileOptions
{
ContentTypeProvider = contentTypeProvider
});
With this configuration, I am still able to load .map
files when I browse to them. What can I do to prevent this?
The issue here was that I was using the local development setup which proxies through Node. When this is the case, the proxy handles the static files instead of ASP.NET Core. I had to switch it up and use the published code to test.