我正在关注azure移动应用服务here的教程。
使用Cordova azure客户端时,身份验证工作正常。但是,在浏览器上,我在chrome控制台中收到以下错误:
XMLHttpRequest cannot load http://MYAPP.azurewebsites.net/tables/Users?.
The request was redirected to 'https://MYAPP.azurewebsites.net/tables/Users?',
which is disallowed for cross-origin requests that require preflight.
解决方法是使用--disable-web-security标志运行chrome。但是,我想知道是否有办法解决这个问题。
我已将天蓝色门户中的CORS设置为*,我认为它允许所有来源
答案 0 :(得分:2)
您需要在门户中配置CORS设置,以允许托管Web服务器的主机的域。例如,如果您在地址栏中输入https://www.mywebsite.com/之类的内容以点击您的移动应用程序,则需要将www.mywebsite.com添加到CORS设置中。
我还注意到请求正从http重定向到https。对于任何经过身份验证的请求,Azure都需要https(以防止JWT令牌在中间攻击中受到攻击),并且如果请求在http上,则会重定向。您需要更改构建器中的URL,以便移动应用客户端使用HTTPS。