AJAX と Tastypie を使用して HTTP リクエストを実行しようとすると、Tastypie リソースに ApiKeyAuthentication を使用しているときに次のエラーが発生します。
XMLHttpRequest cannot load http://domain.com/api/v1/item/?format=json&username=popo&api_key=b83d21e2f8bd4952a53d0ce12a2314c0ffa031b1. Request header field Authorization is not allowed by Access-Control-Allow-Headers.
これを解決する方法についてのアイデアはありますか?
Chrome からのリクエスト ヘッダーは次のとおりです。
Request Headersview source
Accept:*/*
Accept-Charset:
ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:
origin, authorization, access-control-allow-origin, accept, access-control-allow-headers
Access-Control-Request-Method:
GET
Chrome からの応答ヘッダーは次のとおりです。
Response Headersview source
Access-Control-Allow-Headers:
Origin,Content-Type,Accept,Authorization
Access-Control-Allow-Methods:
POST,GET,OPTIONS,PUT,DELETE
Access-Control-Allow-Origin:*
Connection:keep-alive
Content-Length:0
Content-Type:
text/html; charset=utf-8
Date:Fri, 11 May 2012 21:38:35 GMT
Server:nginx
ご覧のとおり、どちらにも承認用のヘッダーがありますが、承認は機能しません。
応答ヘッダーを編集するために使用しているdjangoミドルウェアは次のとおりです: https://gist.github.com/1164697
編集:私は問題を理解しました。www.domain.com に接続しようとしましたが、domain.com しか受け付けません。