neoish's avatar
Level 10

405 method not allowed strange error

I have Laravel Passport installed and also Dingo API on my Laravel 5.4 installation. However, every time I hit POST /oauth/token on POSTMAN and get a 405 Method Not Allowed exception.

Disabling Dingo does not change anything. it is running in a Docker container if that changes anything (I doubt it does). i run php artisan route:list and the Laravel Passport routes are there but hitting it fails.

0 likes
5 replies
neoish's avatar
Level 10

Okay I have narrowed it down to Nginx, is there anyway Nginx could be interfering with this?

emilianotisato's avatar

I have same Isue, and works fine in my local LAMP, but in production (nginx server) have this 405 error!

(I am also running Laravel 5.4)

pingtech's avatar

@neo@creativitykills.co I am seeing the same issue. What did you find out?

pingtech's avatar

@neo@creativitykills.co So here is what I found. Not sure your setup is similar to mine, but I was using vaporbash and vagrant. The net result is that I had a Nginx install on Ubuntu. The base nginx site file /etc/nginx/sites-available had a location code block that redirected "/".

Check your nginx conf and ensure that "/" is properly directed to the application routing:

location / {
            try_files $uri $uri/ /index.php?$query_string;
        }
1 like
codymoorhouse's avatar

Not sure if this helps anyone, but all I had to do was remove the "www" from my url.

I have SSL enabled and when I use "www"nginx redirects me to my site without the "www". Because of this redirect, postman will follow it and drop its headers / parameters (meaning it also switches it back the default GET request).

Depending on how your NGINX is configured, you may need to try some of the following (i.e. myurl.com/oauth/token):

Note: I explicitly use the protocol in all the urls (https)

You can check your NGINX access log to see if it was throwing redirects:

tail -n 10 /var/log/nginx/access.log

You can see the 301(redirect) after the request

50.65.214.191 - 2 [12/Oct/2019:23:47:11 +0000] "POST /oauth/token HTTP/1.1" 301 169 "-" "PostmanRuntime/7.18.0"

Please or to participate in this conversation.