0

I have a React application and i've been trying to make axios requests to an API ignoring SSL verification like this:

const https = require('https');
const axios = require('axios');

const agent = new https.Agent({  
  rejectUnauthorized: false
});

axios.get('https://example.com', { httpsAgent: agent });

But I have this error:

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
        - install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "https": false }

The React app was created using npm create-react-app. I've tried to install https via npm install https, and to install https-browserify, but got the same error.

I'm using nodejs v16.13.2 and react 18.1.0

Why am I getting this error?. Thanks in advance.

pelusa
  • 41
  • 1
  • 8
  • 1
    Did you try following the advice in the error message and install `https-browserify` and set the `resolve.fallback` property? Did you read the error message at all? – Phil May 30 '22 at 06:28
  • Yes, I've installed https-browserify, but the error persists – pelusa May 30 '22 at 06:31
  • Since React runs in the browser and therefore so does Axios, I don't think you can bypass browser SSL validation this way – Phil May 30 '22 at 06:32
  • You don't need to install https because it's a built in module.`const https = require('node:https');` – ChalanaN May 30 '22 at 08:26

1 Answers1

-1

first please check if your website is working on HTTPS or HTTP if your site is running on HTTP then you might add SSL for request handling or if your site is running on HTTPS then it's coming because the server-side is blocking your request you can use CORS package in server-side for allowing non secure origin it worked for me.

TechnoDeveloper
  • 50
  • 1
  • 10