// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { MapperConfig.CreateDTOMaps(); app.UseCors(policy => { policy.AllowAnyHeader(); policy.AllowAnyMethod(); policy.AllowAnyOrigin(); policy.AllowCredentials(); policy.WithExposedHeaders("token"); //跨域时允许自定义响应头暴露出来,否则前端无法获取token,而且不能为空,否则也取不到 }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseResponseCompression(); app.UseHttpsRedirection(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "WorkflowDemo API"); c.RoutePrefix = "swagger"; c.DocExpansion(DocExpansion.None); }); app.UseSwagger(); app.UseAuthentication(); app.UseStaticFiles(); //ConfigHangfire(app); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot")), RequestPath = new PathString("/files") }); app.UseMvc(routes => { routes.MapRoute( name: "defaultWithArea", template: "{area}/{controller=Home}/{action=Index}/{id?}"); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapSpaFallbackRoute("spa-fallback", new { controller = "Home", action = "Index" }); }); }