Skip to content

crypto is not defined #61

@its-dibo

Description

@its-dibo

I got this error

 ReferenceError: crypto is not defined
0|mobarmegeen-backend  |     at hmac (node_modules/aws4fetch/dist/aws4fetch.cjs.js:223:21)
0|mobarmegeen-backend  |     at AwsV4Signer.signature (node_modules/aws4fetch/dist/aws4fetch.cjs.js:185:27)
0|mobarmegeen-backend  |     at AwsV4Signer.authHeader (node_modules/aws4fetch/dist/aws4fetch.cjs.js:177:34)
0|mobarmegeen-backend  |     at AwsV4Signer.sign (node_modules/aws4fetch/dist/aws4fetch.cjs.js:164:52)
0|mobarmegeen-backend  |     at AwsClient.sign (node_modules/aws4fetch/dist/aws4fetch.cjs.js:56:57)
0|mobarmegeen-backend  |     at AwsClient.fetch (node_modules/aws4fetch/dist/aws4fetch.cjs.js:69:40)
0|mobarmegeen-backend  |     at FilesCloudflareService.save (/apps/src/api/files/fs-providers/files.cloudflare.service.ts:54:8)
0|mobarmegeen-backend  |     at /apps/src/api/posts/posts.service.ts:135:10
0|mobarmegeen-backend  |     at matcher (/apps/src/api/files/files.utils.ts:47:14)
0|mobarmegeen-backend  |     at replaceAsync (/apps/src/api/files/files.utils.ts:90:9)
0|mobarmegeen-backend  |     at extractInlineData (/apps/src/api/files/files.utils.ts:52:7)
0|mobarmegeen-backend  |     at PostsService.saveFiles (/apps/src/api/posts/posts.service.ts:121:29)
0|mobarmegeen-backend  |     at PostsService.updateById (/apps/src/api/posts/posts.service.ts:45:17)
0|mobarmegeen-backend  |     at PostsController.update (/apps/src/api/posts/posts.controller.ts:104:25)
0|mobarmegeen-backend  |     at node_modules/@nestjs/core/router/router-execution-context.js:38:29
0|mobarmegeen-backend  |     at processTicksAndRejections (node:internal/process/task_queues:95:5)
0|mobarmegeen-backend  |     at async node_modules/@nestjs/core/router/router-execution-context.js:46:28
0|mobarmegeen-backend  |     at async Object.<anonymous> (node_modules/@nestjs/core/router/router-proxy.js:9:17)

the code:

let client = new AwsClient({
      accessKeyId: ***,
      secretAccessKey: ***!,
    });

let baseUrl =  `https://${accountId}.r2.cloudflarestorage.com`

client
      .fetch(`${baseUrl}/file.txt`, {
        method: 'put',
        body: 'test',
      })

I don't use crypto anywhere in my code
even installing crypto doesn't help npm i crypto

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions