对我的azure应用程序代理进行jQuery调用时,我会收到以下错误
XMLHttpRequest无法加载回调。飞行前的响应无效(重定向)
这就是我要做的
这是我的密码
//authorization context
var resource = 'https://azentsearchdev01-mytenant.msappproxy.net/';
var endpoint = 'https://azentsearchdev01-mytenant.msappproxy.net/search?text=mytext&type=json&callback=json_callback';
var authContext = new AuthenticationContext({
instance: 'https://login.microsoftonline.com/',
tenant: 'mytenant.onmicrosoft.com',
clientId: 'guid for client id',
postLogoutRedirectUri: window.location.origin,
cacheLocation: 'localStorage'
});
//save tokens if this is a return from AAD
authContext.handleWindowCallback();
var user = authContext.getCachedUser();
if (user) { //successfully logged in
authContext.acquireToken("https://graph.windows.net", function (error, token) {
if (error || !token) {
jQuery("#loginMessage").text('ADAL Error Occurred: ' + error);
return;
}
$.ajax({
type: 'GET',
url: endpoint,
headers: {
Accept: 'application/json',
},
beforeSend: function(xhr, settings) {
xhr.setRequestHeader('Authorization','Bearer ' + token);
}
}).done(function (data) {
jQuery("#loginMessage").text('success');
}).fail(function (err) {
jQuery("#loginMessage").text('Error calling endpoint: ' + err.statusText); **-->This is where the code lands**
});
到目前为止-
根据我所读到的,这是当前浏览器如何处理CORS飞行前重定向的一个已知的差距。参考链接。
问题-
是否有任何选择可以成功地调用需要cors飞行前重定向的应用程序?
发布于 2017-05-24 02:17:11
为了克服Azure AD应用程序代理的CORS问题,我们可以为Azure AD应用程序代理开发一个代理。
如果有人想要使用Azure应用代理来支持CORS,你可以通过此链接投票。
https://stackoverflow.com/questions/43955808
复制相似问题