|
@@ -5,12 +5,15 @@ using System.Security.Claims;
|
|
|
using System.Text;
|
|
|
using System.Text.Encodings.Web;
|
|
|
using System.Text.Unicode;
|
|
|
+using HaBookCms.AzureCosmos.ServiceExtension;
|
|
|
using HaBookCms.AzureStorage.ServiceExtension;
|
|
|
using HaBookCms.Common.LogHelper;
|
|
|
+using HaBookCms.ContextConfig.Attributes;
|
|
|
using HaBookCms.ContextConfig.Exceptions;
|
|
|
using HaBookCms.Jwt.Filter;
|
|
|
using HaBookCms.Jwt.Model;
|
|
|
using HaBookCms.RedisStorage.Cache;
|
|
|
+using HaBookCms.ServiceOptions.Options;
|
|
|
using log4net;
|
|
|
using log4net.Config;
|
|
|
using log4net.Repository;
|
|
@@ -65,7 +68,11 @@ namespace HaBookCms.Contest
|
|
|
options.MinimumSameSitePolicy = SameSiteMode.None;
|
|
|
});
|
|
|
|
|
|
-
|
|
|
+ services.AddAzureCosmosDB().AddCosmosDBConnection(new AzureCosmosDBOptions() {
|
|
|
+ ConnectionString = Configuration["AppSettings:Azure:CosmosDBConnection:AccountEndpoint"],
|
|
|
+ ConnectionKey= Configuration["AppSettings:Azure:CosmosDBConnection:AccountKey"],
|
|
|
+ Database = Configuration["AppSettings:Azure:CosmosDBConnection:Database"],
|
|
|
+ });
|
|
|
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
|
|
//services.AddMvc().AddMvcOptions(
|
|
|
// option =>
|
|
@@ -195,7 +202,16 @@ namespace HaBookCms.Contest
|
|
|
#region 性能 压缩
|
|
|
services.AddResponseCompression();
|
|
|
#endregion
|
|
|
- }
|
|
|
+
|
|
|
+ //跨域//设置了允许所有来源
|
|
|
+ services.AddCors(options =>
|
|
|
+ options.AddPolicy("any",
|
|
|
+ builder => builder.AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin().AllowCredentials()));
|
|
|
+ services.AddMvc(options =>
|
|
|
+ {
|
|
|
+ options.Filters.Add(new AllowCorsAttribute());
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|