// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, ILogger <Startup> logger) { StoragePath.Initialize(env.ContentRootPath); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { //app.UseMiddleware<ExceptionHandlerMiddleware>(); app.UseExceptionHandler("/Error"); app.UseHsts(); app.UseStaticFiles(); app.UseSpaStaticFiles(); } app.InitializeDatabaseAsync(Configuration).Wait(); app.UseEntityFrameworkLoggingScopeStateProvider(); app.UseHttpsRedirection(); app.UseRouting(); app.UseCors("CorsPolicy-public"); app.UseIdentityServer(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseAuthorization(); app.UseSwaggerUi3(settings => { settings.OAuth2Client = new OAuth2ClientSettings { ClientId = IdentityServerValues.DocumentationClientId, ClientSecret = IdentityServerValues.DocumentationClientSecret }; settings.Path = "/docs"; settings.DocumentPath = "/docs/api-specification.json"; }); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute("default", "{controller}/{action=Index}/{id?}"); endpoints.MapHealthChecks("/health"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { if (Configuration["UseProxyToSpaDevelopmentServer"] == "True") { spa.UseProxyToSpaDevelopmentServer("http://localhost:4200"); } else { spa.UseAngularCliServer(npmScript: "serve"); spa.Options.StartupTimeout = TimeSpan.FromSeconds(120); } } }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, ILogger <Startup> logger) { StoragePath.Initialize(env.ContentRootPath); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.InitializeDatabase(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseEntityFrameworkLoggingScopeStateProvider(); app.UseHttpsRedirection(); app.UseStaticFiles(); if (!env.IsDevelopment()) { app.UseSpaStaticFiles(); } app.UseRouting(); app.UseCors(builder => builder .AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod()); app.UseIdentityServer(); app.UseAuthorization(); app.UseSwaggerUi3(settings => { settings.OAuth2Client = new OAuth2ClientSettings { ClientId = IdentityServerValues.DocumentationClientId, ClientSecret = IdentityServerValues.DocumentationClientSecret }; settings.Path = "/docs"; settings.DocumentPath = "/docs/api-specification.json"; }); //app.UseCookiePolicy(); //app.UseAuthentication(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute("default", "{controller}/{action=Index}/{id?}"); endpoints.MapHealthChecks("/health"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { //spa.UseAngularCliServer(npmScript: "serve"); //spa.Options.StartupTimeout = TimeSpan.FromSeconds(120); // Increase the timeout if angular app is taking longer to startup spa.UseProxyToSpaDevelopmentServer("http://localhost:4200"); // Use this instead to use the angular cli server } }); }