Fuse Community

TypeError: Network request failed on HTTPS

Hi

i’m doing request with fetch to HTTPS server, which has selfsigned certificate:

 fetch('https://198.206.134.30/test_post', {
            method: 'POST',
            headers: {
                 "Authorization": "Basic dGVzdHVzZXI6dGVzdHBhc3M=",
                 "content-type": "application/x-www-form-urlencoded"
            },
            body: "username=q&passwd=q"
        }).then(function(response) {
            return response.json();            
        }).then(function(responseObject) {
            console.log('responseObject);
        }).catch(function (err) {
            console.log("err: " + err);
        });
 fetch('https://198.206.134.30/test_get', {
            method: 'GET',
            headers: {
                 "Authorization": "Basic dGVzdHVzZXI6dGVzdHBhc3M="
            }
        }).then(function(response) {
            return response.json();            
        }).then(function(responseObject) {
            console.log('responseObject);
        }).catch(function (err) {
            console.log("err: " + err);
        });

Always i get error: TypeError: Network request failed

** It works correctly over curl: **

req: curl -X GET -H "Authorization: Basic dGVzdHVzZXI6dGVzdHBhc3M=" "https://198.206.134.30/test_get" -k

res: TEST SSL GET - OK

req: curl -X POST -H "Authorization: Basic dGVzdHVzZXI6dGVzdHBhc3M=" -H "Content-Type: application/x-www-form-urlencoded" -d 'username=q&passwd=q' "https://198.206.134.30/test_post" -k

res: TEST SSL POST - OK

** but only with parameter -k, --insecure Allow connections to SSL sites without certs **

Any ideas, how is possible do request on HTTPS server with selfsigned certificate, also with some parameter for doing connect without certs, like do it curl ?

Hi,

I’m not sure about the details of your specific issue, but I can see that we have several HTTPS-related issues on file already and this will be worked on over the next few weeks.

Is this working in other fetch based environments ? (e.g. Node.js)

Primary issue is, that fetch has problem with selfsigned certificate. When i do HTTPS request on site with signed certificate by CA, then fetch works correctly.

Any progress on this problem ?
https://data.smartbydata.no/api/3/action/package_search?fq=tags:Kart
It does not work in the simulator. But it works on the android device.

I guess you are talking about preview on mac and not on the actual simulated devices you have in xcode right? If that is the case, we have not fixed this yet. But we are working on rewriting http on that target.

Just wanna check if there are any update or workaround with this issue.

There is no other workaround other than using the ios simulator for preview on Mac. The new implementation is currently in testing internally but I’m not sure in what release it will roll out.

Great to know, Anders. Looking forward to the upcoming update. Thanks.

Hello every one,

i’m having the same error like @Donald: “TypeError: Network request failed” while using Android simulator and i don’ t have Mac. Any update about this issue?

Thanks in avance