|
40 | 40 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. |
41 | 41 | app.UseHsts(); |
42 | 42 | } |
43 | | -app.Use(async (context, next) => |
| 43 | +if (!app.Environment.IsDevelopment()) |
44 | 44 | { |
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 | + |
58 | 82 | if (!app.Environment.IsDevelopment()) |
59 | 83 | { |
60 | 84 | app.UseHttpsRedirection(); |
|
0 commit comments