Is it possible to use the nodejs https agent module, providing the .cert and .key files in Vercel functions?
I have this code:
const httpsAgent = new Agent({
cert: process.env.CERTIFICATE,
key: process.env.KEY,
rejectUnauthorized: true,
})
const interApi = axios.create({
baseURL: process.env.BASE_URL,
httpsAgent,
})
I use the https agent to make requests to this API. Everything works on localhost, but I have this error on Vercel:
Error: error:0480006C:PEM routines::no start line
at node:internal/tls/secure-context:70:13
at Array.forEach (<anonymous>)
at setCerts (node:internal/tls/secure-context:68:3)
at configSecureContext (node:internal/tls/secure-context:186:5)
at Object.createSecureContext (node:_tls_common:116:3)
at Object.connect (node:_tls_wrap:1763:48)
at Agent.createConnection (node:https:171:22)
at Agent.createSocket (node:_http_agent:340:26)
at Agent.addRequest (node:_http_agent:288:10)
at new ClientRequest (node:_http_client:334:16)
at p.request (/var/task/.next/server/app/[slug]/page.js:2579:29132)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async h (/var/task/.next/server/app/[slug]/page.js:61:157225)
at async p (/var/task/.next/server/app/[slug]/page.js:61:157124)
at async f (/var/task/.next/server/app/[slug]/page.js:61:158205)
at async u (/var/task/.next/server/app/[slug]/page.js:61:155563)
at async /var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:418
at async rR (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:15:7978)
at async r7 (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:18:1144)
at async es (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:16:26324) {
library: 'PEM routines',
reason: 'no start line',
code: 'ERR_OSSL_PEM_NO_START_LINE',
digest: '1423523602'
}