Fetch() for http works on Windows but not on MacOS

Fetch() for http works on Windows but not on MacOS. Sample code.

This works on Windows but not on MacOS

fetch('http://gde.cz').then(function (response) {
	return response.text();
}).then(function (html) {
	console.log(html);
}).catch(function (err) {
	console.warn('Something went wrong.', err);
});

This works on both

fetch('https://gde.cz').then(function (response) {
	return response.text();
}).then(function (html) {
	console.log(html);
}).catch(function (err) {
	console.warn('Something went wrong.', err);
});

Why is that? I want to use it only for localhost. But with this, I would need to do something very complicated about certificates.

Use 127.0.0.1 instead; that should work.

Applications on macOS are subject to App Transport Security and both XD and Photoshop enforce this. This means that UXP plugins are subject to the same restrictions.

2 Likes

Please add this into documentation if it is not there. :slight_smile:

1 Like

@kerrishotts Does this also apply to fetch calls to urls with self-signed certificates?
Is there any way around making fetch calls to either of these scenarios (http or https with self-sign certs)?