Skip to content

Commit de9110e

Browse files
committed
Refactor for production
1 parent b972a08 commit de9110e

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

WebApi/Startup.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,29 @@ public class Startup
3232
public Startup(IConfiguration configuration, IHostingEnvironment env)
3333
{
3434
Configuration = configuration;
35+
Env = env;
3536
}
3637

3738
public IConfiguration Configuration { get; }
39+
public IHostingEnvironment Env { get; }
3840

3941
// This method gets called by the runtime. Use this method to add services to the container.
4042
public void ConfigureServices(IServiceCollection services)
4143
{
42-
string SecretKey = Configuration["AppSecret"];
43-
// string SecretKey = "141FE29A91D7FA1A13F3C713BB789";
44-
SymmetricSecurityKey _signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(SecretKey));
44+
string secretKey = string.Empty;
45+
46+
if(Env.IsDevelopment())
47+
{
48+
// Get secret key from dotnet user secrets.
49+
secretKey = Configuration["AppSecret"];
50+
}
51+
else
52+
{
53+
// Set up secretkey for production.
54+
secretKey = "__YOUR_PRODUCTION_SECRET_KEY__";
55+
}
56+
57+
SymmetricSecurityKey _signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(secretKey));
4558

4659
// Add framework services.
4760
services.AddDbContext<ApplicationDbContext>(options =>

WebApi/web.config

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
<configuration>
33
<system.webServer>
44
<modules>
5-
<remove name="WebDAVModule" />
5+
<!-- Allow PUT,DELETE,ETC request headers -->
6+
<remove name="WebDAVModule" />
67
</modules>
78
<handlers>
89
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
910
</handlers>
10-
<aspNetCore processPath="dotnet" arguments=".\WebApi.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
11+
<aspNetCore processPath="dotnet" arguments=".\WebApi.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
1112
</system.webServer>
1213
</configuration>

WebApi/wwwroot/.gitkeep

Whitespace-only changes.

WebApi/wwwroot/index.html

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)