我有一个基于laravel的应用程序,它在本地运行良好,但在服务器上却不能正常工作。
应用程序托管在nginx上,除了GET请求外,PUT、POST、DELETE请求都可以向API发送授权头。
当我调用route时,我也进行了调试
Route::get('reports/{amount}','ReportsController@show');
授权标头未到达API,但它
确实存在
当我将路由方法更改为POST时:
Route::post('reports/{amount}','ReportsController@show');
授权标头到达API。
这是服务器的nginx配置:
server {
listen 80;
listen [::]:80;
client_max_body_size 10M;
#add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Frame-Options 'allow-from https://www.someweb.com';
add_header X-Frame-Options 'allow-from https://www.someweb.com';
add_header X-Content-Type-Options nosniff;
add_header 'Referrer-Policy' 'strict-origin';
add_header X-XSS-Protection "1; mode=block";
root /var/www/html;
index index.html index.htm index.nginx-debian.html, index.php;
error_page 404 /404.html;
include snippets/fastcgi-php.conf;
location /security {
alias /var/www/html/security/public;
try_files $uri $uri/ @security;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
}
location @security {
rewrite /security/(.*)$ /security/index.php?/$1 last;
}
}
我不是很熟悉nginx,但我没有看到任何排除头或GET请求。有人遇到过这个问题吗?
有没有办法找出问题所在?由于我的浏览器有标题,而API没有得到它,我认为这是服务器的错误,但我不知道如何修复它。