When my backend service calls a third-party API (Kamer van koophandel) to retrieve data, it requires a certificate to be set. It functions correctly locally, but upon pushing to Heroku, the following error occurs:
Warning: Ignoring extra certs from `Private_G1_chain.pem`, load failed: error:02001002:system library:fopen:No such file or directory
Warning: Ignoring extra certs from `Private_G1_chain.pem`, load failed: error:02001002:system library:fopen:No such file or directory
Warning: Ignoring extra certs from `Private_G1_chain.pem`, load failed: error:02001002:system library:fopen:No such file or directory
Warning: Ignoring extra certs from `Private_G1_chain.pem`, load failed: error:02001002:system library:fopen:No such file or directory
gyp: Call to 'node -p "require('node-addon-api').include"' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/tmp/build_e15be358/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:376:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Linux 4.4.0-1088-aws
gyp ERR! command "/tmp/build_e15be358/.heroku/node/bin/node" "/tmp/build_e15be358/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/tmp/build_e15be358/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/tmp/build_e15be358/node_modules/bcrypt/lib/binding/napi-v3" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
gyp ERR! cwd /tmp/build_e15be358/node_modules/bcrypt
gyp ERR! node -v v14.17.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/tmp/build_e15be358/.heroku/node/bin/node /tmp/build_e15be358/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/tmp/build_e15be358/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node --module_name=bcrypt_lib --
I have set the correct config var in Heroku: NODE_EXTRA_CA_CERTS = Private_G1_chain.pem
Interestingly, if I push my application to Heroku first and then set NODE_EXTRA_CA_CERTS, it works. However, if NODE_EXTRA_CA_CERTS is set before the push, I encounter the above error.
Just for reference, my application is built with node/express and uses typescript.
Thank you for your help!