Syntax Error in Angular App: Unexpected token <

后端 未结 30 2098
独厮守ぢ
独厮守ぢ 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:33

    I have a webapi project and angular, after trying different ways, following resolved the redirection issue for me

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
    
            //For angular url rewriting
            app.Use(async (context, next) =>
            {
                await next();
                if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value))
                {
                    context.Request.Path = "/index.html";
                    await next();
                }
            })
            .UseDefaultFiles(new DefaultFilesOptions { DefaultFileNames = new List { "index.html" } })
            .UseStaticFiles();
    
            app.UseAuthentication();
    
            app.UseMvc();
        }
    

提交回复
热议问题