Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

670
Views
How can I send a self-signed certificate through axios in the browser?

I am working on a create-react-app that queries an API that requires a self-signed certificate to validate the request. I am grabbing the certificate through a GET request and using a helper to create a new Agent. My initial solution was to assign the httpsAgent in axios.interceptor to attach the certificate to every axios call.

But from what I understand the httpsAgent object is not being passed correctly to index.js because index.js runs in the browser and https is a core node module.

Is there a browser equivalent to https or an alternative method to sending the certificate to the back end? I saw a suggestion to proxy API requests and add the certificate that way, but I am unsure if that's the way to proceed.

Thanks so much!!

httpsAgent.js

const https = require('https');

const createAgent = (data) => {
  const httpsAgent = new https.Agent({
    ca: data,
    rejectUnauthorized: true,
    checkServerIdentity() {
      return undefined;
    },
  });
  return httpsAgent;
};

index.js

axios
  .get('/certificate.pem')
  .then(({ data }) => {
    httpsAgent = createAgent(data);
  })
  .catch((err) => {
    console.log(err);
  })
  .finally(() => {
    axios.interceptors.request.use((config) => {
      const newConfig = {
        ...config,
        httpsAgent,
      };
      return newConfig;
    });
  });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!