|
@@ -20,12 +20,14 @@ namespace MySystem
|
|
|
{
|
|
{
|
|
|
public class Startup
|
|
public class Startup
|
|
|
{
|
|
{
|
|
|
- public Startup(IConfiguration configuration)
|
|
|
|
|
|
|
+ public Startup(IConfiguration configuration, IWebHostEnvironment env)
|
|
|
{
|
|
{
|
|
|
Configuration = configuration;
|
|
Configuration = configuration;
|
|
|
|
|
+ _env = env;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public IConfiguration Configuration { get; }
|
|
public IConfiguration Configuration { get; }
|
|
|
|
|
+ private readonly IWebHostEnvironment _env;
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.s
|
|
// This method gets called by the runtime. Use this method to add services to the container.s
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
public void ConfigureServices(IServiceCollection services)
|
|
@@ -37,9 +39,10 @@ namespace MySystem
|
|
|
});
|
|
});
|
|
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
|
|
services.Configure<Setting>(Configuration.GetSection("Setting"));
|
|
services.Configure<Setting>(Configuration.GetSection("Setting"));
|
|
|
- // 测试完成后必须注释掉
|
|
|
|
|
- services.AddCors(option => option.AddPolicy("cors", policy => policy.AllowAnyHeader().AllowAnyMethod().AllowCredentials().SetIsOriginAllowed(_ => true)));//是否允许跨域
|
|
|
|
|
- // 测试完成后必须注释掉
|
|
|
|
|
|
|
+ if(_env.IsProduction())
|
|
|
|
|
+ {
|
|
|
|
|
+ services.AddCors(option => option.AddPolicy("cors", policy => policy.AllowAnyHeader().AllowAnyMethod().AllowCredentials().SetIsOriginAllowed(_ => true)));//是否允许跨域
|
|
|
|
|
+ }
|
|
|
services.Configure<KestrelServerOptions>(x => x.AllowSynchronousIO = true).Configure<IISServerOptions>(x => x.AllowSynchronousIO = true);
|
|
services.Configure<KestrelServerOptions>(x => x.AllowSynchronousIO = true).Configure<IISServerOptions>(x => x.AllowSynchronousIO = true);
|
|
|
services.AddMvc(options =>
|
|
services.AddMvc(options =>
|
|
|
{
|
|
{
|