Syntax Error in Angular App: Unexpected token <

后端 未结 30 2147
独厮守ぢ
独厮守ぢ 2020-12-02 20:16

I have an Angular app which runs perfectly in my local and production environment.. After a tiny change I made, I ran the app locally and it works fine.. Then I built the pr

30条回答
  •  长情又很酷
    2020-12-02 20:38

    .NET Core solution if you use SpaStaticFile service collection extension and API project for example.

    Base href: /

    // ConfigureServices
    // Correct RootPath to your angular app build, based on angular.json prop
    services.AddSpaStaticFiles(configuration =>
    {
        configuration.RootPath = "App/dist";
    });
    
    // Configure
    // In order to serve files
    app.UseStaticFiles(new StaticFileOptions
    {
        FileProvider = new PhysicalFileProvider(
        Path.Combine(Directory.GetCurrentDirectory(), "App", "dist")),
        RequestPath = ""
    });
    

提交回复
热议问题