File tree 3 files changed +16
-11
lines changed
3 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 19
19
</ItemGroup >
20
20
21
21
<ItemGroup >
22
- <PackageReference Include =" Microsoft.AspNetCore.Authentication.JwtBearer" Version =" 3.1.4" />
23
- <PackageReference Include =" Microsoft.AspNetCore.Cors" Version =" 2.2.0" />
24
- <PackageReference Include =" Microsoft.AspNetCore.Rewrite" Version =" 2.2.0" />
25
- <PackageReference Include =" Microsoft.AspNetCore.Server.Kestrel.Https" Version =" 2.2.0" />
26
- <PackageReference Include =" Microsoft.VisualStudio.Web.CodeGeneration.Design" Version =" 3.1.3" />
27
-
28
- <PackageReference Include =" Swashbuckle.AspNetCore" Version =" 5.4.1" />
29
- <PackageReference Include =" Swashbuckle.AspNetCore.Annotations" Version =" 5.4.1" />
30
- <PackageReference Include =" Swashbuckle.AspNetCore.Swagger" Version =" 5.4.1" />
22
+ <PackageReference Include =" Microsoft.AspNetCore.Authentication.JwtBearer" Version =" 3.1.9" />
23
+ <PackageReference Include =" Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version =" 3.1.9" />
24
+ <PackageReference Include =" Microsoft.VisualStudio.Web.CodeGeneration.Design" Version =" 3.1.4" />
25
+
26
+ <PackageReference Include =" Swashbuckle.AspNetCore" Version =" 5.6.3" />
27
+ <PackageReference Include =" Swashbuckle.AspNetCore.Annotations" Version =" 5.6.3" />
28
+ <PackageReference Include =" Swashbuckle.AspNetCore.Swagger" Version =" 5.6.3" />
31
29
</ItemGroup >
32
30
33
31
<ItemGroup >
Original file line number Diff line number Diff line change @@ -41,13 +41,19 @@ public void ConfigureServices(IServiceCollection services)
41
41
} ) ;
42
42
AuthConfigurer . Configure ( services , Configuration ) ;
43
43
44
+ var origins = Configuration . GetSection ( "CorsUrls" ) . Value . Split ( "," ) ;
44
45
services . AddCors ( options => options . AddPolicy ( _defaultCorsPolicyName ,
45
46
builder =>
46
- builder . AllowAnyOrigin ( )
47
+ builder . WithOrigins ( origins )
47
48
. AllowAnyHeader ( )
48
49
. AllowAnyMethod ( ) . AllowCredentials ( )
49
50
) ) ;
50
- services . AddControllers ( ) ;
51
+ services . AddControllers ( )
52
+ . AddNewtonsoftJson ( options =>
53
+ {
54
+ options . SerializerSettings . ReferenceLoopHandling = Newtonsoft . Json . ReferenceLoopHandling . Ignore ;
55
+ options . SerializerSettings . DateFormatString = "yyyy-MM-dd HH:mm:ss" ;
56
+ } ) ; ;
51
57
services . AddSwaggerGen ( c =>
52
58
{
53
59
c . SwaggerDoc ( "v1" , new OpenApiInfo { Title = "APIJSON.NET" , Version = "v1" } ) ;
Original file line number Diff line number Diff line change 4
4
"ConnectionString" : " Server=192.168.2.25;Database=yunwei;Uid=root;Pwd=xmjk;Port=3306;Character Set=utf8;"
5
5
//"ConnectionString": "Server=119.29.9.25;Port=3306;Database=test;Uid=root;Pwd=1q,2w.3e?;CharSet=UTF8;"
6
6
},
7
+ "CorsUrls" : " http://localhost:5000,http://localhost5001" ,
7
8
"Authentication" : {
8
9
"JwtBearer" : {
9
10
"IsEnabled" : " true" ,
You can’t perform that action at this time.
0 commit comments