#TypeError i.connect is not a function mysql2
5 messages · Page 1 of 1 (latest)
Also, uh, since you deployed this, consider your db credentials invalid now, do whatever you must so that no one can access your database with the credentials
because I know on localhost can't push/insert in db.
How do you know this is the case?
As your credentials have been leaked to client side
this should be wrapped in an api call (or a getServerSideProps) and then it should work
api: https://nextjs.org/docs/api-routes/introduction
SSR: https://nextjs.org/docs/api-reference/data-fetching/get-server-side-props
Also if you go for the API route, you don't need it to be in the NextJS, you can have it elsewhere.
It's a security feature, not a bug, that you cannot directly connect to your database from your client, you wouldn't want your users to arbitrarily DROP TABLE Users;