Open its-dibo opened 9 months ago
Where are you running this? As the README says, this is "for environments that support fetch and SubtleCrypto"
Where are you running this? As the README says, this is "for environments that support fetch and SubtleCrypto"
in a Nodejs app which supports fetch
Which Node.js version? Which OS?
Sent from Gmail Mobile
On Mon, 29 Jan 2024 at 7:30 pm, Dibo @.***> wrote:
AwsClient
in a Nodejs app which supports fetch
— Reply to this email directly, view it on GitHub https://github.com/mhart/aws4fetch/issues/61#issuecomment-1914196492, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACZ2QDN2NCCD2BFITRRBOTYQ5MY5AVCNFSM6AAAAABCBBRG2GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJUGE4TMNBZGI . You are receiving this because you commented.Message ID: @.***>
Which Node.js version? Which OS?
Node v20 OS: ubuntu 22
Not sure what's wrong with your env – it's defined for me:
$ node
Welcome to Node.js v20.11.0.
Type ".help" for more information.
> typeof crypto
'object'
HI
I tried adding const crypto = require('crypto');
to the top of the code then it works.
I am day1 on nodejs using fedora with node output:
$ node
Welcome to Node.js v18.18.2.
Type ".help" for more information.
> typeof crypto
'object'
May it wouldbe of help.
I tried adding
const crypto = require('crypto');
this wo'nt work here because aws4fetch is an external package and we cannot modify its code base
@its-dibo , try adding the Vercel Edge Runtime Polyfill (https://edge-runtime.vercel.app/packages/ponyfill) package:
pnpm add @edge-runtime/ponyfill
then to use it:
import { crypto } from '@edge-runtime/ponyfill'
In case anyone is having this problem running Nuxt
locally, you can create a plugin as follows:
export default defineNuxtPlugin(() => {
const config = useRuntimeConfig();
if (process.server && config.public.env.toLocaleLowerCase() !== 'prod') {
const crypto = require('crypto');
global.crypto = crypto;
}
})
I tried adding
const crypto = require('crypto');
I am experiencing the same issue on both my local node.js environment and also when deploying on google cloud functions:
Simply adding const crypto = require('crypto'); to the beginning of aws4fetch.cjs.js fixes the problem on my local environment. But I can't do this when deploying to GCF. Could this one line be added as per aws4.js ?
I got this error
the code:
I don't use
crypto
anywhere in my code even installing crypto doesn't helpnpm i crypto