Commit cf5f9405 by lizefeng

处理跨域问题

parent 83279e0a
...@@ -38,24 +38,12 @@ namespace AutoTurnOver ...@@ -38,24 +38,12 @@ namespace AutoTurnOver
; ;
//services.Configure<CookiePolicyOptions>(options =>
//services.AddCors(options =>
//{ //{
// options.AddPolicy("AllowSpecificOrigin", // // This lambda determines whether user consent for non-essential cookies is needed for a given request.
// builder => // options.CheckConsentNeeded = context => false;//关闭GDPR规范
// builder // options.MinimumSameSitePolicy = SameSiteMode.None;
// .WithOrigins("http://127.0.0.1:8848")
// .WithOrigins("http://aims.bailuntec.com")
// .AllowAnyOrigin()
// );
//}); //});
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => false;//关闭GDPR规范
options.MinimumSameSitePolicy = SameSiteMode.None;
});
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
...@@ -70,16 +58,16 @@ namespace AutoTurnOver ...@@ -70,16 +58,16 @@ namespace AutoTurnOver
app.UseHsts(); app.UseHsts();
} }
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
app.UseHttpsRedirection(); //app.UseHttpsRedirection();
// 跨域配置 // 跨域配置
//app.UseCors(builder => //app.UseCors(builder =>
//builder.WithOrigins("http://uiaims.bailuntec.com") //builder.WithOrigins("http://aims.bailuntec.com")
//.AllowAnyMethod() //.AllowAnyMethod()
//.AllowAnyHeader() //.AllowAnyHeader()
//.AllowCredentials() //.AllowCredentials()
//); //);
app.UseMiddleware<CorsMiddleware>();
app.UseMvc(routes => app.UseMvc(routes =>
{ {
routes.MapRoute( routes.MapRoute(
...@@ -90,7 +78,7 @@ namespace AutoTurnOver ...@@ -90,7 +78,7 @@ namespace AutoTurnOver
// Shows UseCors with CorsPolicyBuilder. // Shows UseCors with CorsPolicyBuilder.
//app.UseCors("AllowSpecificOrigin"); //app.UseCors("AllowSpecificOrigin");
app.UseMiddleware<CorsMiddleware>();
app.UseStaticHttpContext(); app.UseStaticHttpContext();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment