All apis are working just fine when serving locally but when i try to deploy the app in vercel/ heroku, the apis give me internal error code 500.
So i tried to make a "test api " called hello, it worked just fine until i tried to open connection with db ( query was working locally but in production it gave me internal error)
Here is my code
const mysql= require("mysql2/promise")
export default async function hello(req, res) {
const db= await mysql.createConnection({
host:"eu-cdbr-west-02.cleardb.net",
user:"########",
password:"####",
database:'####',
port:'3306',
})
const [results] = await db.execute("select * from ##",[])
db.end()
res.json(results)
}
Update: On heroku, the api is taking 10 seconds to respond back