01-18-2020 02:25 - edited 02-01-2020 00:44
01-18-2020 02:25 - edited 02-01-2020 00:44
Hi,
TypeError: failed to fetch from Fitbit Ionic over port 443 (but works with port 80), which I setting up API server with nginx and self-signed certificate and I works fine when testing from others with postman to GET/POST over port 80 and 443
How can i fix fetch with self-sign? may i guess it cause of certification verify during fetch.
Mobile OS: iOS
Permission Grant: "access_internet",
Error message: TypeError: Failed to fetch
Example Code:
fetch(`https://192.168.1.100/api/v1/test`, {
method: "POST",
body: `data=test-sent-over-https`,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "asdlkfjapoifhsld'alsjdk;fasakfd"
}
})
.then((res) => {
return res.json()
.then((res) => {
console.log(`response: ${JSON.stringify(res)}`);
});
})
.catch((err)=>{
console.log(err);
});
01-18-2020 02:51
01-18-2020 02:51
I just found below topic but i not sure my problem is the same thing:-
02-01-2020 00:40 - edited 02-01-2020 00:40
02-01-2020 00:40 - edited 02-01-2020 00:40
Any ideas?
02-01-2020 11:35
02-01-2020 11:35
I've spent many hours trying to get companion fetch() to accept a self-signed certificate, but have failed. The certificate works fine via a browser, but that's probably because the browser can set a security exception.
02-01-2020 11:44
02-01-2020 11:44
Hi,
Today i just go back to read Fetch API documents of Fitbit again, I not sure when below description added to the page, but it think it related with my problem:-
fetch()
This API is used to GET and POST across a network.
Please note: fetch() can only be used to access https endpoints and resources, except when accessing resources on a local network by IP address.
So, that my problem cause of Fitbit fetch cannot accessing to local network by IP address.
02-01-2020 11:52
02-01-2020 11:52
You're right. But I can't get fetch to work with http on a LAN server accessed via IP. I wonder if it may be limited to specific IPs and/or ports (which may have the side-effect of limiting it to localhost).
02-01-2020 12:51
02-01-2020 12:51
Further to the theory about specific IPs, see this.
I think I've reached the conclusion that fetch over LAN requires https with a not-self-signed certificate.