Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 75101d6

Browse files
committed
Merge branch 'master' of https://github.com/liaozb/APIJSON.NET
2 parents f7584dc + 0525f90 commit 75101d6

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

‎APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@
1919
</ItemGroup>
2020

2121
<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" />
3129
</ItemGroup>
3230

3331
<ItemGroup>

‎APIJSON.NET/APIJSON.NET/Startup.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,19 @@ public void ConfigureServices(IServiceCollection services)
4141
});
4242
AuthConfigurer.Configure(services, Configuration);
4343

44+
var origins = Configuration.GetSection("CorsUrls").Value.Split(",");
4445
services.AddCors( options => options.AddPolicy( _defaultCorsPolicyName,
4546
builder =>
46-
builder.AllowAnyOrigin()
47+
builder.WithOrigins(origins)
4748
.AllowAnyHeader()
4849
.AllowAnyMethod().AllowCredentials()
4950
));
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+
}); ;
5157
services.AddSwaggerGen(c =>
5258
{
5359
c.SwaggerDoc("v1", new OpenApiInfo { Title = "APIJSON.NET", Version = "v1" });

‎APIJSON.NET/APIJSON.NET/appsettings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"ConnectionString": "Server=192.168.2.25;Database=yunwei1.8;Uid=root;Pwd=xmjk;Port=3306;Character Set=utf8;"
55
//"ConnectionString": "Server=119.29.9.25;Port=3306;Database=test;Uid=root;Pwd=1q,2w.3e?;CharSet=UTF8;"
66
},
7+
"CorsUrls": "http://localhost:5000,http://localhost5001",
78
"Authentication": {
89
"JwtBearer": {
910
"IsEnabled": "true",

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /