Hello Petter Cavallin,
Welcome to the Microsoft Q&A forum.
Based on the error message you provided, it seems that the issue is related to SSL certificate validation. When you use a private endpoint to connect to an Azure SQL Database, the SSL certificate presented by the server may not match the hostname used to connect to the server. This can cause SSL certificate validation to fail.
If you are using a private link FQDN, you may need to configure your client to trust the server certificate. This can be done by setting the TrustServerCertificate property to True in your connection string of the java script
Ex: if you want to use *.privatelink.sql.azuresynapse.net to connect to server instead of *.sql.azuresynapse.net, you need to trust server certificate
You can test this part using SSMS
The issue was resolved after checking the trust server certificate
I hope this helps. Please let me know if you have any further questions.