So I accidentally found something weird and can't figure out why is it.
I make this curl in my terminal (which is ZSH on iTerm):
curl -I https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find\?text\=1%20TX%2077979\&f\=json
And the response is:
HTTP/2 200
date: Wed, 28 Oct 2020 17:31:12 GMT
content-type: application/json;charset=UTF-8
content-length: 374
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
server:
etag: dc0a3f17
x-esri-ftiles-cache-compress: true
cache-control: max-age=300
x-cached: MISS
vary: Origin,Accept-Encoding
strict-transport-security: max-age=31536000
But if I run the same curl as exec child_process in node (v14.14.0) like this:
const { exec } = require('child_process');
const url = 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find\?text\=1%20TX%2077979\&f\=json';
return exec(`curl -I ${url}`, (err, std) => {
console.log(std);
});
The response look like this:
HTTP/2 403
date: Wed, 28 Oct 2020 17:17:18 GMT
content-type: text/html;charset=utf-8
content-length: 680
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
server:
Can anyone explain it to me?
----- EDIT -----
To andrew: I was using urls that contains '&' but they ended with '&query=' which is not obligatory and it still returned HTTP 200 and other needed info, that's why I didn't even notice.