我正在开发一个带有laravel后端的ember.js应用程序.如果出现问题,我正试图用php返回http错误代码.我注意到,当发出PUT请求并返回400状态代码时,我的conf文件会被我的conf文件忽略,这会破坏我的前端.我不知道为什么PUT/400代码组合让nginx忽略我的conf.任何帮助将非常感激.
server {
listen *:80 ;
server_name userchamp.com;
access_log /var/log/nginx/embertest.com.access.log;
location / {
root /var/www/embertest/public;
try_files $uri $uri/ /index.php?$args ;
index index.html index.htm index.php;
}
location ~ \.php$ {
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, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, …Run Code Online (Sandbox Code Playgroud) nginx ×1