HTTP リダイレクトが発生すると、Chrome がクロスオリジン AJAX リクエストをキャンセルするという不可解な問題が発生しています。[ネットワーク] タブでは、「(キャンセル済み)」と表示され、応答ヘッダーまたは本文は使用できません。
フローは次のとおりです。
- http:// でページを読み込む
- https:// のログイン エンドポイントへの POST 要求
- 303 応答
- リクエストがキャンセルされました。
これがJSです(からajaxtest.html
):
var r = new XMLHttpRequest();
r.open('POST', 'https://dev.example.com/appName-rest/login', true);
r.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
r.send(JSON.stringify({"username":"myusername","password":"myrealpassword"}));
r.send();
Chrome のネット内部は、サーバーが次のヘッダーで応答したことを示しています。
HTTP/1.1 303 See Other
Date: Thu, 05 Sep 2013 17:54:21 GMT
Server: Apache/2
Access-Control-Allow-Origin: http://dev.example.com
Access-Control-Allow-Credentials: true
Location: https://dev.example.com/appName-rest/j_spring_cas_security_check?ticket=xxxx.example.com
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 52
Connection: close
Content-Type: text/plain; charset=UTF-8
そしてそれは言う: URL_REQUEST_BLOCKED_ON_DELEGATE
これが失敗する理由を誰かが知っていますか?