@netlify/plugin-csp-nonce 1.2.11 → 1.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/__csp-nonce.ts +5 -19
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@netlify/plugin-csp-nonce",
4
- "version": "1.2.11",
4
+ "version": "1.2.12",
5
5
  "description": "Use a nonce for the script-src and style-src directives of your Content Security Policy.",
6
6
  "main": "index.js",
7
7
  "repository": {
@@ -19,27 +19,8 @@ type Params = {
19
19
  const params = inputs as Params;
20
20
 
21
21
  const handler = async (request: Request, context: Context) => {
22
- const isGET = request.method === "GET";
23
- // We only need to run this for HTTP GET requests.
24
- // If it is not a GET, then return early.
25
- //
26
- // If we instead used `context.next(request)`
27
- // we would be passing the request through this
28
- // edge function for no useful reason.
29
- if (!isGET) {
30
- return;
31
- }
32
-
33
-
34
- // At this point, we know it's a GET request,
35
- // we have to now make the request, in order to
36
- // see what the HTTP response's content-type is.
37
22
  const response = await context.next(request);
38
23
 
39
- let header = params.reportOnly
40
- ? "content-security-policy-report-only"
41
- : "content-security-policy";
42
-
43
24
  // for debugging which routes use this edge function
44
25
  response.headers.set("x-debug-csp-nonce", "invoked");
45
26
 
@@ -55,6 +36,10 @@ const handler = async (request: Request, context: Context) => {
55
36
  return response;
56
37
  }
57
38
 
39
+ let header = params.reportOnly
40
+ ? "content-security-policy-report-only"
41
+ : "content-security-policy";
42
+
58
43
  // CSP_NONCE_DISTRIBUTION is a number from 0 to 1,
59
44
  // but 0 to 100 is also supported, along with a trailing %
60
45
  // @ts-ignore
@@ -197,6 +182,7 @@ export const config: Config = {
197
182
  .filter(Boolean),
198
183
  handler,
199
184
  onError: "bypass",
185
+ method: "GET",
200
186
  };
201
187
 
202
188
  export default handler;