将我的 Asp Net Core Angular Spa 部署到共享 Web 服务器后,对 Angular 运行时组件的请求将返回我的 index.html 文件。
编辑(重新表述问题以使其清晰):
我有一个有角度的水疗中心,由 asp net core 角度模板提供服务。当我导航到应用程序的 url 时,会返回索引页面,然后返回客户端应用程序的脚本文件的后续调用也会返回 index.html...即使该 url 正在请求 runtime.js、main.js 文件。 js等
除了下面我的代码摘录之外,还需要什么额外的配置?
public void ConfigureServices(IServiceCollection services)
{
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist";
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseStaticFiles();
app.UseSpaStaticFiles();
app.UseMvc();
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
});
}
Run Code Online (Sandbox Code Playgroud)
在我的 angular.json 中,我指定了以下 URL 前缀:
"baseHref": "/APPNAME/",
"deployUrl": "/APPNAME/ClientApp/dist/"
Run Code Online (Sandbox Code Playgroud)
源树似乎是正确的。
对每个运行时组件的请求都是成功的,但它们都返回我的index.html,而不是请求的内容。
请求网址:https ://example.com/MYAPP/ClientApp/dist/main.17cf96a7a0252eeecd9e.js
Chrome 网络调试器的响应:
<!doctype html>
<html lang="en">
<head> …Run Code Online (Sandbox Code Playgroud)