aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Startup.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-04-21 22:39:42 +0800
committercrupest <crupest@outlook.com>2019-04-21 22:39:42 +0800
commitedac531b7c0bfc40bc9b6f5c6f1abe71f71cd9e0 (patch)
tree02aceff5fe6a540a1f4b0d4f7253f75cafeb160a /Timeline/Startup.cs
parenta9f248ad817683e911348cd168c570db3d07757f (diff)
downloadtimeline-edac531b7c0bfc40bc9b6f5c6f1abe71f71cd9e0.tar.gz
timeline-edac531b7c0bfc40bc9b6f5c6f1abe71f71cd9e0.tar.bz2
timeline-edac531b7c0bfc40bc9b6f5c6f1abe71f71cd9e0.zip
Remove unnecessary columns in database query.
Diffstat (limited to 'Timeline/Startup.cs')
-rw-r--r--Timeline/Startup.cs32
1 files changed, 15 insertions, 17 deletions
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs
index 0c8d7052..285dfcfa 100644
--- a/Timeline/Startup.cs
+++ b/Timeline/Startup.cs
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
@@ -36,26 +37,16 @@ namespace Timeline
options.InputFormatters.Add(new StringInputFormatter());
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
- if (Environment.IsDevelopment())
- {
- services.AddCors(options =>
- {
- options.AddPolicy(corsPolicyName, builder =>
- {
- builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials();
- });
- });
- }
- else
+ services.AddCors(options =>
{
- services.AddCors(options =>
+ options.AddPolicy(corsPolicyName, builder =>
{
- options.AddPolicy(corsPolicyName, builder =>
- {
+ if (Environment.IsProduction())
builder.WithOrigins("https://www.crupest.xyz", "https://crupest.xyz").AllowAnyMethod().AllowAnyHeader().AllowCredentials();
- });
+ else
+ builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials();
});
- }
+ });
services.Configure<JwtConfig>(Configuration.GetSection(nameof(JwtConfig)));
var jwtConfig = Configuration.GetSection(nameof(JwtConfig)).Get<JwtConfig>();
@@ -80,7 +71,14 @@ namespace Timeline
services.AddDbContext<DatabaseContext>(options =>
{
- options.UseMySql(databaseConfig.ConnectionString);
+ options.UseMySql(databaseConfig.ConnectionString)
+ .ConfigureWarnings(warnings =>
+ {
+ if (Environment.IsProduction())
+ warnings.Log(RelationalEventId.QueryClientEvaluationWarning);
+ else
+ warnings.Throw(RelationalEventId.QueryClientEvaluationWarning);
+ });
});
}