这绝不是一个安全的解决方案…但这是我目前在我的设置,它是工作。也许你可以根据自己的需要修改它。请大家告诉我这有多不对,也许我们可以为大家找到更好的解决方案。
location / {
dav_methods PUT DELETE MKCOL COPY MOVE;
# Preflighted requestis
if ($request_method = OPTIONS) {
add_header "Access-Control-Allow-Origin" *;
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD, DELETE";
add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
return 200;
}
# CORS WHITELIST EVERYTHING
# This is allowing everything because I am running
# locally so there should be no security issues.
if ($request_method = (GET|POST|OPTIONS|HEAD|DELETE)) {
add_header "Access-Control-Allow-Origin" *;
add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
}
try_files $uri $uri/ /index.php$is_args$args;
}