arcgis-js-api - 将标头值添加到磁贴请求
问题描述
有没有办法在 ArcGIS 4.9 中向切片请求添加标头值。我正在使用WebTileLayer
并且我正在连接的磁贴服务器使用 Azure Active Directory 身份验证,这需要在每个磁贴请求的标头中传递详细信息。
我试过使用拦截器
esriConfig.request.interceptors = [{
urls: [/atlas.microsoft.com/],
before: async function (params) {
params.requestOptions.headers = {
'x-ms-client-id': clientId,
Authorization: 'Bearer ' + token
};
}
}];
我也试过:
esriConfig.request.interceptors.push({
urls: [/atlas.microsoft.com/],
authMode: 'anonymous',
headers: {
'x-ms-client-id': clientId,
Authorization: 'Bearer ' + token
}
});
但标头值永远不会添加到磁贴请求中。
解决方案
Finally figured it out. In versions 4.9 and below of ArcGIS JavaScript API, headers are ignored on image requests. This was fixed in version 4.10.
In my case the following added the headers I needed to tile requests once I pointed to version 4.10:
esriConfig.request.interceptors.push({
urls: [/atlas.microsoft.com/],
headers: {
'x-ms-client-id': clientId,
Authorization: 'Bearer ' + token
}
});
推荐阅读
- javascript - 从数据列表中选择一个选项并将索引号与第二个数据列表中的另一个选项进行比较
- javascript - 在 JavaScript 中构建 HTML 的最佳实践
- typo3 - 选择新语言后的typo3语言选择器问题
- powershell - powershell system.object 数组到字符串
- java - 安装了两个 Visual Studio:VS2015 和 VS2017。在VS2017中,查看activity_main.xml时遇到问题
- git - GitLab 在哪里构建应用程序?
- docker - Docker TICK Sandbox 不提供 UDF Python 功能
- instagram - Instagram API 关闭时第三方应用程序如何访问数据?
- css - 对空白使用媒体断点?
- c# - 将布尔值从一个窗口传递到另一个窗口