diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed2cab8..e0a90e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -171,3 +171,25 @@ jobs: for ((i=0; i ( +
+

Welcome to Next.js

+
+) diff --git a/lib/util.js b/lib/util.js index 22a14c8..68b1d9d 100644 --- a/lib/util.js +++ b/lib/util.js @@ -90,7 +90,18 @@ async function createHMACSHA256(secret, data) { // In Node 18 the `crypto` global is behind a --no-experimental-global-webcrypto flag if (typeof crypto === "undefined" && typeof require === "function") { - crypto = require("node:crypto").webcrypto; + // NOTE: Webpack (primarily as it's used by Next.js) and perhaps some + // other bundlers do not currently support the `node` protocol and will + // error if it's found in the source. Other platforms like CloudFlare + // will only support requires when using the node protocol. + // + // As this line is purely to support Node 18.x we make an indirect request + // to the require function which fools Webpack... + // + // We may be able to remove this in future as it looks like Webpack is getting + // support for requiring using the `node:` protocol. + // See: https://github.com/webpack/webpack/issues/18277 + crypto = require.call(null, "node:crypto").webcrypto; } const key = await crypto.subtle.importKey(