Skip to content

Commit fcbec01

Browse files
committed
Development en productie eigen CSP headers gegeven zodat Localhost niet toegestaan is in de productie omgeving.
1 parent e52c001 commit fcbec01

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

ShowcaseProject/ShowcaseFrontend/Program.cs

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,45 @@
4040
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
4141
app.UseHsts();
4242
}
43-
app.Use(async (context, next) =>
43+
if (!app.Environment.IsDevelopment())
4444
{
45-
context.Response.Headers.Append("Content-Security-Policy",
46-
"default-src 'self'; " +
47-
"script-src 'self' https://cdnjs.cloudflare.com ; " +
48-
"style-src 'self' 'sha256-xyz4zkCjuC3lZcD2UmnqDG0vurmq12W/XKM5Vd0+MlQ='; " +
49-
"font-src 'self' ; " +
50-
"img-src 'self'; " +
51-
"object-src 'none'; " +
52-
"frame-ancestors 'none'; " +
53-
"base-uri 'self'; " +
54-
"form-action 'self';"+
55-
"connect-src 'self' ws://localhost:* http://localhost:5001 https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/6.0.1/signalr.js.map; ");
56-
await next();
57-
});
45+
app.Use(async (context, next) =>
46+
{
47+
context.Response.Headers.Append("Content-Security-Policy",
48+
"default-src 'self'; " +
49+
"script-src 'self' https://cdnjs.cloudflare.com ; " +
50+
"style-src 'self' ; " +
51+
"font-src 'self' ; " +
52+
"img-src 'self'; " +
53+
"object-src 'none'; " +
54+
"frame-ancestors 'none'; " +
55+
"base-uri 'self'; " +
56+
"form-action 'self';" +
57+
"connect-src 'self' https://frontend-erik.azurewebsites.net " +
58+
"wss://showcaseapi-demo123.eastus.azurecontainer.io " +
59+
"https://showcaseapi-demo123.eastus.azurecontainer.io ; ");
60+
await next();
61+
});
62+
}
63+
else
64+
{
65+
app.Use(async (context, next) =>
66+
{
67+
context.Response.Headers.Append("Content-Security-Policy",
68+
"default-src 'self'; " +
69+
"script-src 'self' https://cdnjs.cloudflare.com ; " +
70+
"style-src 'self' ; " +
71+
"font-src 'self' ; " +
72+
"img-src 'self'; " +
73+
"object-src 'none'; " +
74+
"frame-ancestors 'none'; " +
75+
"base-uri 'self'; " +
76+
"form-action 'self';" +
77+
"connect-src 'self' ws://localhost:* http://localhost:5001; ");
78+
await next();
79+
});
80+
}
81+
5882
if (!app.Environment.IsDevelopment())
5983
{
6084
app.UseHttpsRedirection();

ShowcaseProject/ShowcaseFrontend/wwwroot/js/game.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,9 @@
132132

133133
async function createGameBoard(groupName,playerSymbol) {
134134
const board = document.querySelector("#GameBoard");
135-
//board.setAttribute("style", "display:grid;width: 150px;grid-template-columns: auto auto auto;gap: 5px 5px;");
136135
for (let i = 0; i < 9; i++) {
137136
let span = document.createElement("div");
138137
span.innerHTML = " ";
139-
//span.style = "border:solid;#333333;1px;width:50px;height:50px;";
140138
span.id = "cell" + i;
141139
span.onclick = async () => {
142140
let cell = document.getElementById("cell" + i);

0 commit comments

Comments
 (0)