Certification authority invalid

Viewed 47

i am trying to send an https request from my frontend (reactjs) to backend (nodejs/express).

These two both run in localhost.

Back end server code:

const app = require('./app')
const https = require('https');
const fs = require('fs');

const credentials = {
  key: fs.readFileSync('key.pem'),
  cert: fs.readFileSync('cert.pem')
};

//connect to the database
require('./db')

const port = 8765;

app.get('/', (req, res) => {
   res.send('Now using https..');
});

var server = https.createServer(credentials, app);

//var server = https.createServer(app);

// listen for requests
server.listen(port, () => {
  console.log("server starting on port : " + port)
});

front end request:

const {data: Sessions}= await axios.get("https://localhost:8765/...");

doint this request from postman with the exact same parameters produces the desired result.However when i try to do this from frontend i get: GET https://localhost:8765/... net::ERR_CERT_AUTHORITY_INVALID in react chrome extention.

Why is this happening and how can i solve this?

0 Answers
Related