Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

676
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda