在Docker容器中运行JS脚本时发生意外错误

时间:2020-11-09 16:17:46

标签: javascript node.js docker

因此,当我在Windows终端中运行脚本时,一切正常。我使用的所有库都受Linux支持,但是当我制作Docker Image并运行它时,出现了我的普通终端上没有发生的错误。

TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received undefined

at prepareSecretKey (internal/crypto/keys.js:322:11)

at new Hmac (internal/crypto/hash.js:113:9)

at Object.createHmac (crypto.js:147:10)

at verifyPostData (/usr/src/app/bin/utils/utilFunctions.js:85:35)

at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)

at next (/usr/src/app/node_modules/express/lib/router/route.js:137:13)

at Route.dispatch (/usr/src/app/node_modules/express/lib/router/route.js:112:3)

at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)

at /usr/src/app/node_modules/express/lib/router/index.js:281:22

at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)

当我的脚本验证收到的有效负载时,就会发生这种情况。关于可能发生的事情有什么想法吗?

定义键的位置:

    const sig = req.get('X-Hub-Signature') || '';
    const hmac = crypto.createHmac('sha1', process.env.SECRET!);
    const digest = Buffer.from(
        'sha1=' + hmac.update(payload).digest('hex'),
        'utf8'
    );
    const checksum = Buffer.from(sig, 'utf8');
}

0 个答案:

没有答案