request.interceptors mapimagelayer working

435
2
09-28-2018 01:08 PM
NathanRees
New Contributor

The request headers aren't being sent on MapImageLayers.  but works with FeatureLayers

token = 'sometoken';
api = 'myproxyserver';
esriConfig.request.interceptors.push({
  urls: [`https://${api}v1/GIS/proxy`],
  before: (params) => {
    params.requestOptions.headers = {'Authorization': 'Bearer ' + token};
  },
  headers: {'Authorization': 'Bearer ' + token}
});

looks like it's not being sent with the fetchImage function within MapImageLayer.js ... 

0 Kudos
2 Replies
Noah-Sager
Esri Regular Contributor

I think this is related to the responseType of the esriRequest:

When this value is image the headers and timeout options are ignored.

 

esriRequest - RequestOptions - responseType 

request | API Reference | ArcGIS API for JavaScript 4.9 

 

If this is the case, we will consider making an enhancement at a future release.

0 Kudos
Noah-Sager
Esri Regular Contributor

Hi Nathan, looks like we have this fixed for the upcoming 4.10 release, due out in mid-December. The "headers" will now be honored when the value type is "image". Hope this helps.

 

-Noah

0 Kudos