Skip to content

Unable to use signed urls, problems with importing crypto module #128

@dovca

Description

@dovca

Problem description

When I add signed:true to the options of client.helper.buildSrc(), I get the following error:

URL signing requires Node.js crypto module which is not available in this runtime. Please use Node.js environment for URL signing functionality.
    at createHmacSha1 (node_modules/@imagekit/nodejs/lib/crypto-utils.mjs:23:15)
    at getSignature (node_modules/@imagekit/nodejs/resources/helper.mjs:391:12)
    at Helper.buildSrc (node_modules/@imagekit/nodejs/resources/helper.mjs:79:34)

Upon further investigation, it is because the ES module is trying to call the require function, which does not exist in that context.

Please fix this error by using a static import statement instead of the dynamic require function in the ESM build of @imagekit/nodejs/lib/crypto-utils.mjs

Environment

Bundler: Vite 7.2.2 (under Nuxt 4.2.1)
Node: 24.3.0
@imagekit/nodejs: 7.1.1

Reproduction

https://bolt.new/~/sb1-dslmuuah

  1. Open the linked project
  2. Switch to the code tab <>
  3. Open the Terminal tab
  4. Run node index.mjs
  5. See error in the console

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions