【发布时间】:2020-03-30 20:30:56
【问题描述】:
对于我的后端 API 应用程序,我有 Laravel 6 和 Laravel Passport oAuth2 插件。我是我的routes/web.php 我正在使用Auth::routes(); 制作所有oAuth 路由。我的 Nginx 配置(在 Amazon 实例上运行):
/etc/nginx/conf.d/app.conf
server {
server_name my-app-domain.net;
listen 80;
client_max_body_size 20M;
include /etc/nginx/default.d/*.conf;
root /var/www/app/public;
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.php;
location ~ /\. {
deny all;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
error_page 500 502 503 504 /index.php;
location ~* \.(?:ico|css|otf|gif|jpe?g|png)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control "public";
root /var/www/app/public;
}
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
如果我将带有 grant_type 和其他登录凭据的 POST 发送到 http://<domain name>/oauth/token,我会收到这个奇怪的错误:
"Symfony\Component\HttpKernel\Exception\ MethodNotAllowedHttpException 不支持 GET 方法 路线。支持的方法:POST。”
除此之外,其他 API 请求工作正常,所以可能不是 CORS 限制
但是,如果我运行 php artisan serve 并将 POST 发送到 http://localhost:8080/oauth/token,它会按预期工作
【问题讨论】:
标签: laravel nginx oauth laravel-passport