Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />

<PackageReference Include="Swashbuckle.AspNetCore" Version="5.4.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.4.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.4.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.9" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />

<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.6.3" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 8 additions & 2 deletions APIJSON.NET/APIJSON.NET/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
Expand Down
1 change: 1 addition & 0 deletions APIJSON.NET/APIJSON.NET/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down