我在我的Django的觀點得到這個代碼:nginx的,Django和x_requested_with:request.is_ajax()返回false
if request.is_ajax():
if request.method == 'POST':
data = json.loads(request.raw_post_data)
我送這個請求,通過捲曲:
curl -v -i -H "Content-Type:application/json" -H "X_REQUESTED_WITH:XMLHttpRequest" -X POST -d '{"tweet_id":"189881044923719680", "question_id":"1", "choice_one":"T", "choice_two":"F", "choice_three":"F", "extra_passback":"common cold"}' http://ec[...].compute-1.amazonaws.com/question/answer/
這在我打開我的開發Django服務器時起作用。在製作中我運行nginx和gunicorn。捲曲聲明不起作用。
request.is_ajax()返回False(is_ajax將查找x_requested_with頭)。
我想,這一定有可能與NGINX配置做。但我不確定。我需要改變什麼?
試試這個:http://wiki.nginx.org/HttpProxyModule#proxy_pass_header – ilvar 2012-04-27 05:06:18