【发布时间】:2014-10-31 18:46:40
【问题描述】:
我有一个使用 Yeoman 部署的 AngularJS 应用程序。 Cakephp RESTful 后端。
Angular 应用程序发送 OPTIONS 预检请求,后端以禁止 (403) 响应,在 nginx 中我使用了这个来解决这个问题:
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
add_header 'Access-Control-Allow-Headers' 'X-AuthTokenHeader,Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
如何在 Apache 中执行此操作?请提供一些初步的指导/cmets,之后我会弄清楚细节并用细化的细节改进问题。
【问题讨论】:
标签: apache http-headers