Not able to send a fetch request after using Cloudflare's ssl

after using cloudflares ssl I can’t send a fetch request with https protocol. here is my code:

async function testRun() {


    const url = ``

    const httpsAgent = new https.Agent({
        rejectUnauthorized: false,

    fetch(url, {
        method: 'post',
        agent: httpsAgent
    .then(response => {

        console.log('response', response)
    .then(google_response => {
        console.log('google_response', google_response)
    .catch(error => console.log(error));


I get this error:

 response Response {
 size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: PassThrough {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: true,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: null
disturbed: false,
error: null
[Symbol(Response internals)]: {
url: '',
status: 404,
statusText: 'Not Found',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
google_response undefined

This is working with localhost and I think it may e a SSL or cors issue !

UPDATE: removing the agent from fetch options gives me another aspect of the error:

FetchError: request to failed, reason: Hostname/IP does not match certificate's altnames: Host: is not in the cert's altnames:,
 at ClientRequest.<anonymous> (/home/porsanes/application/node_modules/node-fetch/lib/index.js:1461:11)
at ClientRequest.emit (node:events:394:28)
at TLSSocket.socketErrorListener (node:_http_client:447:9)
 at TLSSocket.emit (node:events:394:28)
 at emitErrorNT (node:internal/streams/destroy:157:8)
 at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
 type: 'system',

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.