Skip to content

Commit

Permalink
Added CSP value for connect-src to enable local domain API calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanLamansky committed Sep 28, 2024
1 parent 50c5b2c commit b0f868a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion HtmlUtilities/HtmlDocumentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static Task WriteToAsync(this IHtmlDocument document, HttpContext context
response.ContentType = "text/html; charset=utf-8";
Span<char> cspNonceUtf16 = stackalloc char[32];
System.Security.Cryptography.RandomNumberGenerator.GetHexString(cspNonceUtf16, true);
response.Headers.ContentSecurityPolicy = $"base-uri {request.Scheme}://{request.Host}/;default-src 'unsafe-inline' 'nonce-{cspNonceUtf16}'";
response.Headers.ContentSecurityPolicy = $"base-uri {request.Scheme}://{request.Host}/;default-src 'unsafe-inline' 'nonce-{cspNonceUtf16}' connect-src: 'self'";
// unsafe-inline only applies to browsers that don't support nonce. Can be removed when security scanners stop asking for it.

var writer = context.Response.BodyWriter;
Expand Down

0 comments on commit b0f868a

Please sign in to comment.