@netlify/plugin-csp-nonce 1.1.2 → 1.1.4
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.
- package/package.json +1 -1
- package/src/__csp-nonce.ts +9 -3
package/package.json
CHANGED
package/src/__csp-nonce.ts
CHANGED
|
@@ -29,14 +29,19 @@ const handler = async (request: Request, context: Context) => {
|
|
|
29
29
|
const isGET = request.method?.toUpperCase() === "GET";
|
|
30
30
|
const isCurl = request.headers.get("user-agent")?.startsWith("curl/");
|
|
31
31
|
const isHTMLRequest =
|
|
32
|
-
request.headers.get("accept")?.
|
|
32
|
+
request.headers.get("accept")?.includes("text/html") ||
|
|
33
|
+
request.headers.get("sec-fetch-dest") === "document" ||
|
|
34
|
+
isCurl;
|
|
33
35
|
const isHTMLResponse = response.headers
|
|
34
36
|
.get("content-type")
|
|
35
37
|
?.startsWith("text/html");
|
|
36
38
|
const shouldTransformResponse = isGET && isHTMLRequest && isHTMLResponse;
|
|
37
39
|
if (!shouldTransformResponse) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
console.log(`Unnecessary invocation for ${request.url}`, {
|
|
41
|
+
method: request.method,
|
|
42
|
+
accept: request.headers.get("accept"),
|
|
43
|
+
"content-type": response.headers.get("content-type"),
|
|
44
|
+
});
|
|
40
45
|
return response;
|
|
41
46
|
}
|
|
42
47
|
|
|
@@ -157,6 +162,7 @@ export const config: Config = {
|
|
|
157
162
|
...excludedExtensions.map((ext) => `**/*.${ext}`),
|
|
158
163
|
],
|
|
159
164
|
handler,
|
|
165
|
+
onError: "bypass",
|
|
160
166
|
};
|
|
161
167
|
|
|
162
168
|
export default handler;
|