Report this

What is the reason for this report?

How do I access a mysql managed db via mysql2 from node.js

Posted on December 20, 2024

i am currently trying to make a raffle ticket system and need to write the ticket numbers to a sql database. However I keep getting an error about self signing certificates. I have downloaded the CA certificate and put its contents into a envelope variable. Everything works fine in development but in production I am getting the self signing certificate error. I am using vercel to host the Web app. Below is the error and the database config.

[nuxt] [request error] [unhandled] [500] self-signed certificate in certificate chain
  at Object.createConnectionPromise [as createConnection] (./node_modules/mysql2/promise.js:18:31)  
  at Object.handler (./chunks/routes/api/webhook.mjs:60:34)  
  at Object.handler (./chunks/runtime.mjs:2837:24)  
  at Object.handler (./chunks/runtime.mjs:3146:34)  
  at Object.handler (./chunks/runtime.mjs:2908:31)  
  at async toNodeHandle (./chunks/runtime.mjs:3178:7)  
  at async Server.<anonymous> (/opt/rust/nodejs.js:9:6760)

const dbConfig={
    host:process.env.MYSQL_HOST,
    user:process.env.MYSQL_USER,
    password:process.env.MYSQL_PASSWORD,
    database:process.env.MYSQL_DATABASE,
    port:process.env.MYSQL_PORT,
    ssl:{
        ca:process.env.CA_CERT,
    }
};

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.