Good Day
A function which retrieves the token for a client, and uses it to authenticate to the hosted feature layer, started failing out of the blue, throwing CORS errors from Angular.
The specific error we're getting is:
Access to fetch at 'https://<client>.geopedia.ca/portal/sharing/rest/generateToken' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
When we try to access the resource using Insomnia or Postman, we can get a token, and the code we used to fetch the token was working fine a couple of weeks ago, this is the function:
const tokenParams = {
username: 'blah',
password: 'blah',
ip: '',
referer: '',
client: 'requestip',
expiration: '60',
f: 'pjson'
}
// -ignore
request(this._tokenURL, {params: tokenParams}).then((esriResponse) => {
request(this.testURL, {params: {token: esriResponse.token}}).then((response) => {
this._featureLayer = _.cloneDeep(response);
r(this._featureLayer.fields);
}).catch((error) => {
console.log('Error');
console.log(error);
j(error);
});
}).catch((error) => {
console.log('Error');
console.log(error);
this.alert.genericError();
j(error);
});
I generated the tokenParams object using: https://<client>.geopedia.ca/portal/sharing/rest/generateToken which will also return a token. I haven't changed anything in this code in weeks, so I have to assume it's either something on the clients side or ESRI's.
Has anyone run into similar issues?
Thanks