diff --git a/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj b/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj
index ca433bf..1a23f95 100644
--- a/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj
+++ b/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj
@@ -19,15 +19,13 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/APIJSON.NET/APIJSON.NET/Startup.cs b/APIJSON.NET/APIJSON.NET/Startup.cs
index 4a0cfb6..756a23c 100644
--- a/APIJSON.NET/APIJSON.NET/Startup.cs
+++ b/APIJSON.NET/APIJSON.NET/Startup.cs
@@ -41,13 +41,19 @@ public void ConfigureServices(IServiceCollection services)
});
AuthConfigurer.Configure(services, Configuration);
+ var origins = Configuration.GetSection("CorsUrls").Value.Split(",");
services.AddCors( options => options.AddPolicy( _defaultCorsPolicyName,
builder =>
- builder.AllowAnyOrigin()
+ builder.WithOrigins(origins)
.AllowAnyHeader()
.AllowAnyMethod().AllowCredentials()
));
- services.AddControllers();
+ services.AddControllers()
+ .AddNewtonsoftJson(options =>
+ {
+ options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
+ options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
+ }); ;
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "APIJSON.NET", Version = "v1" });
diff --git a/APIJSON.NET/APIJSON.NET/appsettings.json b/APIJSON.NET/APIJSON.NET/appsettings.json
index da52e61..610c96b 100644
--- a/APIJSON.NET/APIJSON.NET/appsettings.json
+++ b/APIJSON.NET/APIJSON.NET/appsettings.json
@@ -4,6 +4,7 @@
"ConnectionString": "Server=192.168.2.25;Database=yunwei;Uid=root;Pwd=xmjk;Port=3306;Character Set=utf8;"
//"ConnectionString": "Server=119.29.9.25;Port=3306;Database=test;Uid=root;Pwd=1q,2w.3e?;CharSet=UTF8;"
},
+ "CorsUrls": "http://localhost:5000,http://localhost5001",
"Authentication": {
"JwtBearer": {
"IsEnabled": "true",