I've been facing this error and even after a lot of research on SO, I have not been able to solve it. Here what I did :
- I first have followed the steps indicated here in order to create my self-signed certificate.
- Then, I added it to my Node.js server code :
const express = require('express');const fs = require('fs');const cors = require('cors');const csvParser = require('csv-parser');const https = require('https');const app = express();const port = 30440;app.get('/read-data', (req, res) => { const results = []; fs.createReadStream('data.csv') .pipe(csvParser()) .on('data', (data) => results.push(data)) .on('end', () => { res.json(results); }) .on('error', (error) => { console.error('Error reading CSV:', error); res.status(500).send('Error reading CSV'); });});const private = fs.readFileSync('client-key.pem', 'utf8');const cert = fs.readFileSync('client-cert.pem', 'utf8');const certificate = {key: private, cert: cert};https.createServer(certificate, app).listen(port, '0.0.0.0', () => { console.log(`Server is running on https://grumpycoincat.xyz:${port}`);})- And here is a part of the client code :
const response = fetch('https://IP_ADDRESS:30440/read-data')I'm currently testing in production, because in development the browser doesn't care about the localhost.
Thanks in advance